Re: JDBC parse error with preparedStatement!

Поиск
Список
Период
Сортировка
От Ramin Rad
Тема Re: JDBC parse error with preparedStatement!
Дата
Msg-id 20040112005902.40009.qmail@web9804.mail.yahoo.com
обсуждение исходный текст
Ответ на Re: JDBC parse error with preparedStatement!  (Kris Jurka <books@ejurka.com>)
Список 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@ejurka.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
>


В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Arne Stoelck
Дата:
Сообщение: Re: problem to connect to database
Следующее
От: Ramin Rad
Дата:
Сообщение: Re: JDBC parse error with preparedStatement!