WHY DOES JDBC SHOW DIFFERENT TIMESTAMP FROM SQLPLUS ON DAYLIGHT SAVINGTIME (DST)? (Doc ID 871385.1)

Last updated on MARCH 08, 2017

Applies to:

JDBC - Version: 10.2.0.4 to 11.1.0.7
Information in this document applies to any platform.

Goal

 JDBC 11.1.0.7.0 driver (ojdbc6.jar) using JDK 1.6 against an Oracle 10.2.0.4 database.
SqlPlus and JDBC execution on same select statement on date field show different results.

Is this a bug? Why does JDBC show a different value from sqlplus? 


Steps to reproduce:

1. Create table:

SQL> create table x(a date);


2. Insert values:

SQL> insert into x(a) values(to_date('20090308 01','yyyymmdd hh24'));
SQL> insert into x(a) values(to_date('20090308 02','yyyymmdd hh24'));
SQL> commit;

The date / timestamp in question is 2am on 8th March 2009 - Daylight SavingTime (DST) change- Spring 2009.


3. Perform select statement from sqlplus:

SQL> select rowid, a from x;

ROWID A
------------------ -------------------
AAAOCwAAFAAAAIlAAA 2009-03-08 01:00:00
AAAOCwAAFAAAAIlAAB 2009-03-08 02:00:00



4. Run a simple java program that executes the same statement executed from sqlplus in Step 3:
"SELECT a FROM x
WHERE rowid = 'AAAOCwAAFAAAAIlAAA'
UNION
SELECT a FROM x
WHERE rowid = 'AAAOCwAAFAAAAIlAAB' ");

The result from JDBC is:


2009-03-08 01:00:00.0
2009-03-08 03:00:00.0

Solution

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms