Re: Q: use setObject also for int or string - Mailing list pgsql-jdbc

From Kris Jurka
Subject Re: Q: use setObject also for int or string
Date
Msg-id 48D44523.6030009@ejurka.com
Whole thread Raw
In response to Q: use setObject also for int or string  (Michael Enke <michael.enke@wincor-nixdorf.com>)
Responses Re: PreparedStatement.toString() creates valid SQL; was: Q: use setObject also for int or string  (Michael Enke <michael.enke@wincor-nixdorf.com>)
List pgsql-jdbc
Michael Enke wrote:
> The PreparedStatement.toString() returns the query,
> replaced with available parameter, but string constants are not enclosed
> in apostrophes:
>
> 74: select * from a where a='a'
> 83: select * from a where a=a
>
> The 74 version put this into apostrophes if setString was used.
> If setInt was used, no apostrophes were output.
>

We've never claimed that the output of PreparedStatement.toString would
produce valid SQL.  There are certainly other problems with it than just
missing apostrophes.  It currently doesn't escape values, so it breaks
if your data contains embedded ' or \.  It doesn't understand whether
the server has standard_conforming_strings enabled or not.   What would
it to do with a parameter that is an InputStream?  If the toString code
reads it, the driver cannot re-read it to send it to the server when
executed.

The InputStream is perhaps an unusual case, so I wouldn't be opposed if
someone wanted to make the simple cases work better, but it's not
something I'm particularly excited about.

Kris Jurka

pgsql-jdbc by date:

Previous
From: Kris Jurka
Date:
Subject: Re: Postgresql JDBC UTF8 Conversion Throughput
Next
From: "Addleman, Mark J"
Date:
Subject: COPY support in JDBC driver?