Re: Literal vs parameterized 'timestamp with time zone' value

From: Heikki Linnakangas <heikki(at)enterprisedb(dot)com>
To: Christopher Hunt <huntc(at)internode(dot)on(dot)net>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Literal vs parameterized 'timestamp with time zone' value
Date: 2007-06-18 12:46:59
Message-ID: 46767EC3.3020505@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Christopher Hunt wrote:
> However if I use a parameter:
>
> PreparedStatement sqlStatement =
> sqlConnection.prepareStatement("select validtime from
> moving_object_status where validtime < ?");
> int columnIndex = 1;
> sqlStatement.setString(columnIndex++, "2005-06-08T20:05:45.825+0");
>
> No rows are returned.
>
> Can anyone explain the difference in results given a literal value and a
> parameterised value in this context?

I don't really have an explanation, but I would recommend using
setTimestamp instead of setString for timestamp values.

Maybe there's a time or timezone difference between client and server,
and in the former case the server setting is used, and in the latter,
the client setting?

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2007-06-18 12:51:24 Re: Literal vs parameterized 'timestamp with time zone' value
Previous Message Christopher Hunt 2007-06-18 12:41:07 Re: Literal vs parameterized 'timestamp with time zone' value