Thursday, March 8, 2012

Bug in Microsoft SQL Server 2005 JDBC Driver

I am using the new Microsoft SQL Server 2005 JDBC Driver to connect to ms sql 2000. I am testing GMT date conversions in my application and found a bug in the way the driver converts DateTime columns in the ResultSet.getTimeStamp(int i, Calendar cal) method.

The driver is not converting GMT dates to client time correctly in the time range og April 1, 9:00 pm to 10:00 pm EST through the rs.getTimeStamp(int, Calendar) method. The date is coming back an hour off. In UTC time, this time is April 2, 2:00 AM to April 2, 3:00 AM. I guess daylight savings is confusing it. Can someone get back to me with a work around or verification of this bug. Thanks.

Sequence:

1. Set client and server to April 1, 9:05 PM EST. (This is the day before Daylight savings occurs).

2. Run an query on the client from java using the driver.

Calendar cal = Calendar.getInstance();
cal.setTimeZone(TimeZone..getTimeZone("UTC");
Date d;
ResultSet rs = stmt.executeQuery("SELECT getutcdate()");
while(rs.next())
{
d = rs.getTimeStamp(0, cal);
}

System.err.println(d);

Hi Harry,

I think I already replied to you in private email, but I wanted to make sure others scouring the forum are aware as well. This is a bug in the v1.0 SQL Server 2005 JDBC driver. Microsoft will be providing a QFE with a fix. I'll follow up with another post as soon as it becomes available. We are taking some extra time with the fix to make sure it is correct with respect to the subtle nuances of Java's Calendar object, like Daylight Savings Time start and end dates, and historical time zone offset changes.

Thank you for your patience.

--David Olix

JDBC Development

|||

This bug has been now been fixed as a QFE. Please notify CSS that you would like to get the hotfix for KB article 917055.

Again, thank you for your patience,

--David Olix

JDBC Development

No comments:

Post a Comment