Mapping between SQL types and JDBC types in Oracle is a bit more complicated, especially for DATE and TIMESTAMP SQL types.
The Oracle database allows you to store timestamp information in DATE columns, which is quite contrary to the definition of DATE in the SQL standard. Until 9.2, when TIMESTAMP column support was introduced, Statement.setTimestamp will work for DATE columns. From 9.2 through 11.1, the JDBC driver mapped the SQL DATE type to JDBC DATE and SQL TIMESTAMP to JDBC TIMESTAMP . Possible solutions for storing timestamps using 10.2 JDBC drivers are listed in the Oracle JDBC FAQ and reproduced here:
There are several ways to solve this problem in 9.2-10.2 drivers:
Modify your tables to use TIMESTAMP instead of DATE. This is probably rare, but it is the best solution when it is.
Modify the application to use defineColumnType to define columns as TIMESTAMP, not DATE. There are problems with this because you really don't want to use defineColumnType if you don't need to (see What is defineColumnType and when should I use it?).
Modify the application to use getTimestamp rather than getObject. This is a good solution whenever possible, however many applications contain common code that relies on getObject, so this is not always possible.
Set the V8Compatible connection property. This speaks of JDBC drivers for using the old mapping, not the new one. You can set this flag either as a connection property or as a system property. You set the connection property by adding it to the java.util.Properties object passed to DriverManager.getConnection or OracleDataSource.setConnectionProperties. You set the system property by including the -D option in your java command line.
java -Doracle.jdbc.V8Compatible = "true" MyApp
You can also use the JDBC 11.1 drivers (they will work against the 10g instance), and the FAQ has the following:
Oracle JDBC 11.1 fixes this problem. Starting with this release, the driver maps to SQL DATE columns with java.sql.Timestamp by default. There is no need to install V8Compatible to get the correct display. V8Compatible is strongly discouraged. You should not use it at all. If you make it true, it will not hurt anything, but you must stop using it.
source share