> Upon investigation, it appears H2 is incorrectly adjusting the
> timestamp when calling JdbcPreparedStatement.setTimestamp(int
> parameterIndex, java.sql.Timestamp x, Calendar calendar) (line 654).
Obviously you shouldn't use ValueTimestamp directly. Instead, use the JDBC API.
Did you check what other databases do? According to my test cases, H2
works in the same way as other databases (HSQLDB, Derby,
PostgreSQL,...).
Regards,
Thomas
private void testXXX() throws SQLException {
Connection conn = getConnection("date");
TimeZone defaultTimeZone = TimeZone.getDefault();
Statement stat = conn.createStatement();
stat.execute("create table test(ts timestamp primary key)");
try {
TimeZone.setDefault(TimeZone.getTimeZone("PST"));
DateTimeUtils.resetCalendar();
java.sql.Timestamp date1 = java.sql.Timestamp.valueOf("2010-03-13 18:15:00");
java.sql.Timestamp date2 = java.sql.Timestamp.valueOf("2010-03-13 19:15:00");
Calendar utcCalendar = new GregorianCalendar(new SimpleTimeZone(0, "Z"));
PreparedStatement prep = conn.prepareStatement("INSERT INTO TEST VALUES(?)");
prep.setTimestamp(1, new java.sql.Timestamp(date1.getTime()), utcCalendar);
prep.execute();
prep.setTimestamp(1, new java.sql.Timestamp(date2.getTime()), utcCalendar);
prep.execute();
} finally {
TimeZone.setDefault(defaultTimeZone);
DateTimeUtils.resetCalendar();
}
conn.close();
deleteDb("date");
}
Jamie Clark wrote:
> 2010-03-13 18:15
Thanks a lot for the test case! I can reproduce the problem now, and
I'm working on a solution.
Currently, H2 converts the timestamp to the local timezone before
getting the fields (year, month, day, hour,...). This is doesn't work
in this case, as the converted time doesn't actually exist (due to
summer time change; it's 02:15 am).
I think I can fix this in the next release. Of course I will add your
test case (plus a few more).
Regards,
Thomas
> --
> You received this message because you are subscribed to the Google Groups
> "H2 Database" group.
> To post to this group, send email to h2-da...@googlegroups.com.
> To unsubscribe from this group, send email to
> h2-database...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/h2-database?hl=en.
>
>
This problem is now fixed in the trunk.
Regards,
Thomas