Thread: BUG #6285: PreparedStatement#executeUpdate gets syntax error on apostrophe

BUG #6285: PreparedStatement#executeUpdate gets syntax error on apostrophe

From
"Gary Kenney"
Date:
The following bug has been logged online:

Bug reference:      6285
Logged by:          Gary Kenney
Email address:      gary.kenney@xerox.com
PostgreSQL version: 9.1.1
Operating system:   Windows 7
Description:        PreparedStatement#executeUpdate gets syntax error on
apostrophe
Details:

The value that was assigned via PreparedStatement.setString, was "Gary's
Document".  Note the apostrophe.  Without the apostrophe, there is no error.
 Stack trace:

01 Nov 2011 16:29:09 - [Thread[Thread-63,5,main]] -    at
org.postgresql.util.PSQLException.parseServerError(PSQLException.java:139)
01 Nov 2011 16:29:09 - [Thread[Thread-63,5,main]] -    at
org.postgresql.core.QueryExecutor.executeV3(QueryExecutor.java:152)
01 Nov 2011 16:29:09 - [Thread[Thread-63,5,main]] -    at
org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:100)
01 Nov 2011 16:29:09 - [Thread[Thread-63,5,main]] -    at
org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:43)
01 Nov 2011 16:29:09 - [Thread[Thread-63,5,main]] -    at
org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Statement.j
ava:517)
01 Nov 2011 16:29:09 - [Thread[Thread-63,5,main]] -    at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.j
ava:50)
01 Nov 2011 16:29:09 - [Thread[Thread-63,5,main]] -    at
org.postgresql.jdbc1.AbstractJdbc1Statement.executeUpdate(AbstractJdbc1State
ment.java:273)
:
my code
:
"Gary Kenney" <gary.kenney@xerox.com> writes:
> Description:        PreparedStatement#executeUpdate gets syntax error on
> apostrophe

> The value that was assigned via PreparedStatement.setString, was "Gary's
> Document".  Note the apostrophe.  Without the apostrophe, there is no error.

Right offhand I would guess that you are using an old JDBC driver that
isn't prepared for standard_conforming_strings to be turned on.

If that isn't it, I'd suggest asking for help on the pgsql-jdbc mailing
list; I'm not sure how many of those guys read pgsql-bugs.

            regards, tom lane