pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <heikki@enterprisedb.com>
To: Christopher Hunt <huntc@internode.on.net>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Literal vs parameterized 'timestamp with time zone' value
Date: Mon, 18 Jun 2007 13:46:59 +0100
Message-ID: <46767EC3.3020505@enterprisedb.com> (raw)
In-Reply-To: <094DD6D8-B500-479F-B730-0BFCC256A5DE@internode.on.net>
References: <094DD6D8-B500-479F-B730-0BFCC256A5DE@internode.on.net>

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



view thread (9+ messages)  latest in thread

Message-ID: <46767EC3.3020505@enterprisedb.com>
Permalink:  ../46767EC3.3020505@enterprisedb.com/
Also on:    postgresql.org/message-id/46767EC3.3020505@enterprisedb.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: heikki@enterprisedb.com, huntc@internode.on.net
  Subject: Re: Literal vs parameterized 'timestamp with time zone' value
  In-Reply-To: <46767EC3.3020505@enterprisedb.com>
  References: <094DD6D8-B500-479F-B730-0BFCC256A5DE@internode.on.net> <46767EC3.3020505@enterprisedb.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox