List:MySQL and Java« Previous MessageNext Message »
From:David Morse Date:January 22 2003 9:36pm
Subject:Re: Question about PreparedStatement.setTimestamp(..., Calendar)
View as plain text  
FirstSQL/J 100% Java ORDBMS does support timezone. It one of the few
databases that support SQL92 TIME WITH TIMEZONE and TIMESTAMP WITH TIMEZONE,
along with several other unique and powerful features like Java Stored
Procedures and Java Objects in the database.

http://www.firstsql.com/

Dave M.
----- Original Message -----
From: "Shankar Unni" <shankar@stripped>
To: <java@stripped>
Sent: Tuesday, January 21, 2003 4:45 PM
Subject: Question about PreparedStatement.setTimestamp(..., Calendar)


I asked this on the JDC site, but didn't get much of a response there.
Basically, this is about the precise semantics of the "Calendar"
argument to PreparedStatement.setTimestamp().

Here's what I'd like to do: since most databases don't understand
timezones, I'd like to convert timestamps to UTC equivalents. E.g. I'm
in the Pacific timezone, so if I have a timestamp corresponding to Jan
20, 12 Noon PST, I'd like the database column to be recorded as "Jan 20,
8PM" (because that's what the timestamp would read if it were formatted
using a UTC calendar).

I'm using

   Calendar utc_cal = Calendar.getInstance("UTC")

and am calling

   PreparedStatement ps = ...;
   ps.setTimestamp(n, ts, utc_cal);

What actually happens is that:

* With Oracle, the time gets written into the database as 2003-01-20
20:00:00 (what I'd expect).

* MySQL (connector/J 3.0.4) on the other hand, interprets this as "I'm
saying that I'm in UTC, and so convert it to what the server expects",
so it actually does the opposite transformation: 2003-01-20 04:00:00 is
what gets written into the DB.

Who's correct?

Certainly the language in the Javadoc needs to be tightened
considerably, if two people can read such radically different things
into the spec..


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/doc/         (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <java-thread4935@stripped>
To unsubscribe, e-mail <java-unsubscribe-davem405=attbi.com@stripped>



Thread
Question about PreparedStatement.setTimestamp(..., Calendar)Shankar Unni22 Jan
  • Re: Question about PreparedStatement.setTimestamp(..., Calendar)Mark Matthews22 Jan
    • RE: Question about PreparedStatement.setTimestamp(..., Calendar)Shankar Unni22 Jan
      • Re: Question about PreparedStatement.setTimestamp(..., Calendar)Mark Matthews22 Jan
        • RE: Question about PreparedStatement.setTimestamp(..., Calendar)Shankar Unni22 Jan
          • Re: Question about PreparedStatement.setTimestamp(..., Calendar)Mark Matthews22 Jan
            • RE: Question about PreparedStatement.setTimestamp(..., Calendar)Shankar Unni22 Jan
      • Re: Question about PreparedStatement.setTimestamp(..., Calendar)Mark Matthews22 Jan
  • Re: Question about PreparedStatement.setTimestamp(..., Calendar)David Morse22 Jan