Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 98ADB9FB550 for ; Mon, 12 Mar 2007 10:12:50 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 78000-02 for ; Mon, 12 Mar 2007 10:12:43 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from web60813.mail.yahoo.com (web60813.mail.yahoo.com [209.73.178.236]) by postgresql.org (Postfix) with SMTP id 090379FB544 for ; Mon, 12 Mar 2007 10:12:42 -0300 (ADT) Received: (qmail 81256 invoked by uid 60001); 12 Mar 2007 13:12:41 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=5FfeIRQiO8Fdh7qvfKS9drlbFcQHQ72lAMsisXYuhK9S7Ie4fGmEfymCFvqONVTrGyVrXefKOcwUmdbN75coNYJpo7lK8q/TJ1/u0XRTGHMP1FFUHgV/lUADSKiF5yg3AaaWw5Ou91nPWX+bGrjj6FQ90s5ZI1tSHPtb0BbokLI=; X-YMail-OSG: t2_GIC8VM1mR4LGUgl77aMiBm3VqQZl5GmJxFfOA1XujCOfoCXiyjIUotXawzbm3So396al.jjsrSF5ZmUTihIJebDYsdBZqUw1XpGkfWsSgluyXYS2bqTmDiXZv1j4ZZZigk31kmDGLew6NqLu.2Od_2f4- Received: from [72.245.161.11] by web60813.mail.yahoo.com via HTTP; Mon, 12 Mar 2007 06:12:41 PDT Date: Mon, 12 Mar 2007 06:12:41 -0700 (PDT) From: Jeff Amiel Subject: DST issue with older drivers... To: pgsql-jdbc@postgresql.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1620900877-1173705161=:81156" Content-Transfer-Encoding: 8bit Message-ID: <350073.81156.qm@web60813.mail.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=4.708 tagged_above=0 required=5 tests=BAYES_50, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, DNS_FROM_RFC_WHOIS, HTML_10_20, HTML_MESSAGE X-Spam-Level: **** X-Archive-Number: 200703/95 X-Sequence-Number: 16809 --0-1620900877-1173705161=:81156 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Got bit yesterday by a bit of stupidity on my part. Was hoping someone could shed some light, however on what exactly happen so I can close the issue out and move on. "PostgreSQL 8.1.2 on i386-portbld-freebsd6.0, compiled by GCC cc (GCC) 3.4.4 [FreeBSD] 20050518" (although also had issues with 8.2.X....no reason to believe the postgresql version was a factor) Freebsd servers were 'patched' with latest zoneinfo port and /etc/localtime was 'correct'. My servers are all set to central US time zone (America/Chicago) Java was patched and confirmed with tzupdater. Weirdest thing. Code that has worked through countless DST switchovers suddenly puked on my feet yesterday. I narrowed it down to a simple test case where I simply did a "select now() as thedate" from one of my postgresql databases and extracted the results using jdbc. I output the date/time information beforehand to make sure that the VM knew what timezone and time it should be System.out.println("Date = " + new java.util.Date()); System.out.println("Calendar = " + Calendar.getInstance()); Date = Sun Mar 11 14:50:30 CDT 2007 Calendar = java.util.GregorianCalendar [time=1173642630395,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="America/Chicago",offset=-21600000,dstSavings=3600000,useDaylight=true,transitions=235,lastRule=java.util.SimpleTimeZone[id=America/Chicago,offset=-21600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2007,MONTH=2,WEEK_OF_YEAR=11,WEEK_OF_MONTH=3,DAY_OF_MONTH=11,DAY_OF_YEAR=70,DAY_OF_WEEK=1,DAY_OF_WEEK_IN_MONTH=2,AM_PM=1,HOUR=2,HOUR_OF_DAY=14,MINUTE=50,SECOND=30,MILLISECOND=395,ZONE_OFFSET=-21600000,DST_OFFSET=3600000] All appears well...and then: String stmt = "select now() as thedate"; ps = con.prepareStatement(stmt); rs = ps.executeQuery(); if(rs.next()) { System.out.println("raw date is "+rs.getDate("thedate")); System.out.println("raw date via timestamp is "+rs.getTimestamp("thedate")); } results? 2007-03-11 12:58:53,694 INFO [STDOUT] raw date is 2007-03-10 2007-03-11 12:58:53,694 INFO [STDOUT] raw date via timestamp is 2007-03-11 12:58:53.665499 (yeah...the time is different than the above output...from 2 different runs) It appears that when calling getDate() on a timestamp field yields a different date than getTimestamp in this instance. I had read somewhere that the JDBC specs say to fall back on a passed calendar or use the JVM timezone to calculate the correct date when using getDate()...and the JVM timezone/date/time was correct, so I thought I should have gotten the correct date results. After a bit of searching, I determined I wasn't using the jdbc driver that I thought I was. I THOUGHT I was using postgresql-8.1-407.jdbc3.jar. In actuality, I was using postgresql-8.0-314.jdbc3.jar. Oops. When I switched to the newer driver, all was well. So the question remains....I didn't see anything in the changelog (http://jdbc.postgresql.org/changes.html) AFTER 8.0.314 related to timestamp/date issue. I know it's like closing the barn door after the cow escaped, but I thought I'd see if anyone had any nuggets of info for me. Thanks!! --------------------------------- Need Mail bonding? Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users. --0-1620900877-1173705161=:81156 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Got bit yesterday by a bit of stupidity on my part.
Was hoping someone could shed some light, however on what exactly happen so I can close the issue out and move on.

"PostgreSQL 8.1.2 on i386-portbld-freebsd6.0, compiled by GCC cc (GCC) 3.4.4 [FreeBSD] 20050518"  (although also had issues with 8.2.X....no reason to believe the postgresql version was a factor)

Freebsd servers were 'patched' with latest zoneinfo port and /etc/localtime was 'correct'. 

My servers are all set to central US time zone (America/Chicago)
Java was patched and confirmed with tzupdater.

Weirdest thing.  Code that has worked through countless DST switchovers suddenly puked on my feet yesterday.

I narrowed it down to a simple test case where I simply did a "select now() as thedate" from one of my postgresql databases and extracted the results using jdbc.

I output the date/time information beforehand to make sure that the VM knew what timezone and time it should be

System.out.println("Date = " + new java.util.Date());
System.out.println("Calendar = " + Calendar.getInstance());

Date = Sun Mar 11 14:50:30 CDT 2007
Calendar = java.util.GregorianCalendar [time=1173642630395,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="America/Chicago",offset=-21600000,dstSavings=3600000,useDaylight=true,transitions=235,lastRule=java.util.SimpleTimeZone[id=America/Chicago,offset=-21600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2007,MONTH=2,WEEK_OF_YEAR=11,WEEK_OF_MONTH=3,DAY_OF_MONTH=11,DAY_OF_YEAR=70,DAY_OF_WEEK=1,DAY_OF_WEEK_IN_MONTH=2,AM_PM=1,HOUR=2,HOUR_OF_DAY=14,MINUTE=50,SECOND=30,MILLISECOND=395,ZONE_OFFSET=-21600000,DST_OFFSET=3600000]

All appears well...and then:

String stmt = "select now() as thedate";
ps = con.prepareStatement(stmt);
rs = ps.executeQuery();
if(rs.next()) {
    System.out.println("raw date is "+rs.getDate("thedate"));
    System.out.println("raw date via timestamp is "+rs.getTimestamp("thedate"));
}


results?

2007-03-11 12:58:53,694 INFO  [STDOUT] raw date is 2007-03-10
2007-03-11 12:58:53,694 INFO  [STDOUT] raw date via timestamp is 2007-03-11 12:58:53.665499  (yeah...the time is different than the above output...from 2 different runs)

It appears that when calling getDate() on a timestamp field yields a different date than getTimestamp in this instance.  I had read somewhere that the JDBC specs say to fall back on a passed calendar or use the JVM timezone to calculate the correct date when using getDate()...and the JVM timezone/date/time was correct, so I thought I should have gotten the correct date results.

After a bit of searching, I determined I wasn't using the jdbc driver that I thought I was.  I THOUGHT I was using postgresql-8.1-407.jdbc3.jar. In actuality, I was using postgresql-8.0-314.jdbc3.jar.  Oops.

When I switched to the newer driver, all was well.
So the question remains....I didn't see anything in the changelog (http://jdbc.postgresql.org/changes.html) AFTER 8.0.314 related to timestamp/date issue.  I know it's like closing the barn door after the cow escaped, but I thought I'd see if anyone had any nuggets of info for me.

Thanks!!



Need Mail bonding?
Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users. --0-1620900877-1173705161=:81156--