我在使用PreparedStatement的与时间戳条款:PreparedStatement和的setTimestamp在Oracle JDBC
PreparedStatement s=c.prepareStatement("select value,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
ResultSet rs = s.executeQuery();
if(rs.next()) System.out.println(rs.getInt("value"));
结果我得到的是不同的,当我在客户端计算机上不同的时区。这是Oracle jdbc中的一个错误吗?或正确的行为?
Oracle数据库版本是10.2,我已经尝试使用oracle jdbc瘦驱动程序版本10.2和11.1。
参数是Timestamp,我预计在路上没有时间转换。数据库列类型是DATE,但我也使用TIMESTAMP列类型对其进行了检查,结果相同。
有没有办法实现正确的结果?我无法将整个应用程序中的默认时区更改为UTC。
感谢您的帮助
请编辑您的问题并添加t_begin和t_end的类型。 – 2010-05-18 14:38:43