Re: PreparedStatement error for date parameter with overlaps

Поиск
Список
Период
Сортировка
От Oliver Jowett
Тема Re: PreparedStatement error for date parameter with overlaps
Дата
Msg-id BANLkTimUcH1JCKavKmsjf-4uEQ09=jZnXg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: PreparedStatement error for date parameter with overlaps  (Simon Mitchell <simon@jseb.com>)
Список 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 по дате отправления:

Предыдущее
От: Simon Mitchell
Дата:
Сообщение: Re: PreparedStatement error for date parameter with overlaps
Следующее
От: Craig Ringer
Дата:
Сообщение: Re: PreparedStatement error for date parameter with overlaps