Skip site navigation (1) Skip section navigation (2)

Re: JDBC driver and java strings

From: Kris Jurka <books(at)ejurka(dot)com>
To: Chuck Davis <cjgunzel(at)gmail(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: JDBC driver and java strings
Date: 2006-05-16 18:46:24
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc

On Tue, 16 May 2006, Chuck Davis wrote:

> Does anybody know if there is a plan to make the driver handle java
> strings appropriately?  I have hit a showstopper.  If I enter data in
> a JTextfield with an apostrophe the driver chokes with a syntax error.
> I don't know how IBM does it but their JDBC driver handles
> apostrophes without a problem.  DB2 has been my main database but I'm
> evaluating Postgresql on Linux.  I can't ask my users to avoid
> entering data with an apostrophe and I'm too lazy to program around it
> since I know it can be done otherwise once and for all.

If you use PreparedStatement.setString, any required quoting/escaping 
should be done for you.  If you are building a SQL string yourself than 
you are responsible for escaping it correctly.  You haven't said what 
you're doing, but I find it hard to believe that it's postgresql's fault 
or that DB2 has some magic to interpret bad data.  Perhaps you could be 
more specific in what your code is doing?

Kris Jurka

In response to


pgsql-jdbc by date

Next:From: Chuck DavisDate: 2006-05-16 18:57:04
Subject: Re: JDBC driver and java strings
Previous:From: Kris JurkaDate: 2006-05-16 18:43:01
Subject: Re: COPY rehashed

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group