From: | Ramin Rad <ramin(at)flamenco-teacher(dot)com> |
---|---|
To: | Kris Jurka <books(at)ejurka(dot)com> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: JDBC parse error with preparedStatement! |
Date: | 2004-01-12 00:59:01 |
Message-ID: | 20040112005902.40009.qmail@web9804.mail.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
For what it's worth, I get a different error message if I try to change the
query slightly, from:
String sqlStmt = "DELETE FROM ft_member WHERE username = ?";
to:
String sqlStmt = "DELETE FROM ft_member WHERE username=?";
(notice, removed the spaces around '='.)
Here is the error message:
Exception in thread "main" java.sql.SQLException: ERROR: Unable to identify a
postfix operator '=?' for type 'character varying'
You may need to add parentheses or an explicit cast
at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:131)
at
org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connection.java:505)
at
org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Statement.java:320)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:48)
at
org.postgresql.jdbc1.AbstractJdbc1Statement.executeUpdate(AbstractJdbc1Statement.java:197)
at
org.postgresql.jdbc1.AbstractJdbc1Statement.executeUpdate(AbstractJdbc1Statement.java:183)
And here is what I see in the server log file:
LOG: query: set datestyle to 'ISO'; select version(), case when
pg_encoding_to_char(1) = 'SQL_ASCII' then 'UNKNOWN' else getdatabaseencoding()
end;
LOG: query: set client_encoding = 'UNICODE'; show autocommit
LOG: query: DELETE FROM ft_member WHERE username=?
ERROR: Unable to identify a postfix operator '=?' for type 'character varying'
You may need to add parentheses or an explicit cast
LOG: pq_recvbuf: unexpected EOF on client connection
I also tried falling back to JDK1.3.1, instead of 1.4.2, I recompiled the JDBC
driver and my code with the older version of java. Same error.
Thanks,
-ramin
--- Kris Jurka <books(at)ejurka(dot)com> wrote:
>
>
> On Sun, 11 Jan 2004, Ramin Rad wrote:
>
> >
> > I am getting a very annoying parse error message on a simple delete
> statement:
> >
> > String sqlStmt = "DELETE FROM ft_member WHERE username = ?";
> > PreparedStatement stmt = connection.prepareStatement( sqlStmt );
> > stmt.setString( 1, "test");
> > stmt.executeUpdate( sqlStmt );
> >
> > Here is the error message:
> >
> > Exception in thread "main" java.sql.SQLException: ERROR: parser: parse
> error
> > at end of input
> >
>
> I can't see anything that's going wrong here either. The best way to
> debug this problem is to enable statement loggin on the server so we can
> see the exact query the server tries to run. To do this enable
> log_statement in postgresql.conf and restart the server.
>
> Kris Jurka
>
From | Date | Subject | |
---|---|---|---|
Next Message | Kris Jurka | 2004-01-12 01:25:18 | Re: JDBC parse error with preparedStatement! |
Previous Message | Oliver Jowett | 2004-01-12 00:49:35 | Re: PreparedStatement parameters and mutable objects |