Re: PreparedStatement error for date parameter with overlaps - Mailing list pgsql-jdbc

From Oliver Jowett
Subject Re: PreparedStatement error for date parameter with overlaps
Date
Msg-id BANLkTimUcH1JCKavKmsjf-4uEQ09=jZnXg@mail.gmail.com
Whole thread Raw
In response to Re: PreparedStatement error for date parameter with overlaps  (Simon Mitchell <simon@jseb.com>)
List pgsql-jdbc
On 31 May 2011 15:12, Simon Mitchell <simon@jseb.com> wrote:

> The strange thing is the doing a toString() before executeQuery() prints out
> the sql as per the postgres example, I can cut and past it into psql and it
> runs fine.

PreparedStatement.toString() isn't guaranteed to give you the query as
executed (or even a syntactically correct query!), it just substitutes
parameter values into the query string to give you something that
might be more useful for debugging than the default Object.toString()
implementation.

If you wanted to get the equivalent query in psql, you should take
your query string and replace ? with $1, $2, etc, then use
PREPARE/EXECUTE. That's much closer to how the JDBC driver actually
executes queries; the driver does *not* just substitute values into
the query string.

Oliver

pgsql-jdbc by date:

Previous
From: Simon Mitchell
Date:
Subject: Re: PreparedStatement error for date parameter with overlaps
Next
From: Craig Ringer
Date:
Subject: Re: PreparedStatement error for date parameter with overlaps