I’ve searched around, and surprisingly can’t find an answer to this for Oracle JDBC. This closely related question has answers for PostgreSQL and MySQL.
Basically, if I have two application servers in two different time zones writing timestamps to one Oracle database, what will happen? Thanks.
Edit: I should add that it seems like the value that JDBC is sending to the database when I do queries is in my local time zone.
I put together some test JDBC code to figure out exactly what happens. The results were interesting. Oracle has three closely related datatypes:
TIMESTAMP,TIMESTAMP WITH TIME ZONE, andTIMESTAMP WITH LOCAL TIME ZONE. I took the exact same code, and ran it from two different boxes, one in the “America/New_York” timezone, and one running on UTC. Both hit the same database, running in UTC. I was using the Oracle 11.2.0.2.0 driver.TIMESTAMPcolumn was set to whatever the local time was on the machine executing the Java code. No time zone translation was performed.TIMESTAMP WITH TIME ZONEcolumn translated the time to whatever timezone the JDBC client was in.TIMESTAMP WITH LOCAL TIME ZONEcolumn also translated the time to whatever timezone the JDBC client was in.This article, which is a bit older, indicates that
TIMESTAMP WITH TIME ZONEis pretty much useless if you want to do anything like indexes or partitions. However, it seems likeTIMESTAMP WITH LOCAL TIME ZONEmight be extremely useful. (Not sure what happens if you change the server’s time zone, but it seems to be intelligent about JDBC clients’ local time zones). I haven’t had a chance to test indexing behavior, etc. with these datatypes.Pasting in my sample class below if you’d like to reproduce my tests in your environment.