PreparedStatement and setTimestamp in oracle jdbc

Posted by Roman on Stack Overflow See other posts from Stack Overflow or by Roman
Published on 2010-05-18T14:30:37Z Indexed on 2010/05/20 6:10 UTC
Read the original article Hit count: 215

Hi everyone,

I am using PreparedStatement with Timestamp in where clause:

PreparedStatement s=c.prepareStatement("select utctimestamp from t where utctimestamp>=? and utctimestamp<?"); 
s.setTimestamp(1, new Timestamp(1273017600000L));   //2010-05-05 00:00 GMT
s.setTimestamp(2, new Timestamp(1273104000000L));   //2010-05-06 00:00 GMT

The result I get is different, when I have different time zones on the client computer. Is this a bug in Oracle jdbc? or correct behavior?

The parameter is Timestamp, and I expected that no time conversions will be done on the way. The database column type is DATE, but I also checked it with TIMESTAMP column type with the same results.

Is there a way to achieve correct result? I cannot change default timezone in the the whole application to UTC.

Thanks for your help

© Stack Overflow or respective owner

Related posts about jdbc

Related posts about Oracle