Re: Q: use setObject also for int or string

Поиск
Список
Период
Сортировка
От Kris Jurka
Тема Re: Q: use setObject also for int or string
Дата
Msg-id 48D44523.6030009@ejurka.com
обсуждение исходный текст
Ответ на Q: use setObject also for int or string  (Michael Enke <michael.enke@wincor-nixdorf.com>)
Ответы Re: PreparedStatement.toString() creates valid SQL; was: Q: use setObject also for int or string  (Michael Enke <michael.enke@wincor-nixdorf.com>)
Список 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 по дате отправления:

Предыдущее
От: Kris Jurka
Дата:
Сообщение: Re: Postgresql JDBC UTF8 Conversion Throughput
Следующее
От: "Addleman, Mark J"
Дата:
Сообщение: COPY support in JDBC driver?