Oracle JDBC types mapped to Java object types using getObject () - wrong document?

this is the document link: "Mapping SQL and Java Types"

see 8.9.3 JDBC types mapped to Java object types in a string: TIMESTAMP - java.sql.Timestamp

but when I use getObject () with the oracle database in the TIMESTAMP column, the return type is oracle.sql.TIMESTAMP, it cannot be passed to java.sql.Timestamp

I know that I can use getTimestamp (), but I need getObject () to handle any set of results, regardless of type.

Is the document wrong or me?

+6
source share
1 answer

The document is correct, the Oracle JDBC driver is a problem.

There are 2 possible solutions:

First, use getObject:

oracle.sql.TIMESTAMP ts = (oracle.sql.TIMESTAMP) res.getObject("last_update"); agent.setLastUpdate(new Date(ts.dateValue().getTime())); 

The second is to add the VM argument to your application:

 -Doracle.jdbc.J2EE13Compliant=true 

This will cause the driver to return oracle.sql.TIMESTAMP instead of oracle.sql.TIMESTAMP .

+2
source

All Articles