WHY DOES JDBC SHOW DIFFERENT TIMESTAMP FROM SQLPLUS ON DAYLIGHT SAVINGTIME (DST)?
Last updated on MARCH 08, 2017
Applies to:JDBC - Version: 10.2.0.4 to 220.127.116.11
Information in this document applies to any platform.
JDBC 18.104.22.168.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'));
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;
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'
SELECT a FROM x
WHERE rowid = 'AAAOCwAAFAAAAIlAAB' ");
The result from JDBC is:
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