Re: Q: use setObject also for int or string

From: Kris Jurka <books(at)ejurka(dot)com>
To: Michael Enke <michael(dot)enke(at)wincor-nixdorf(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Q: use setObject also for int or string
Date: 2008-09-20 00:34:43
Message-ID: 48D44523.6030009@ejurka.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Addleman, Mark J 2008-09-20 00:35:02 COPY support in JDBC driver?
Previous Message Kris Jurka 2008-09-19 23:45:59 Re: Postgresql JDBC UTF8 Conversion Throughput