Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Oracle 10g returns DATE as java.sql.Date?
thomas_okken_at_hotmail.com wrote:
> I noticed that Oracle 10g XE, with the ojdbc14.jar JDBC driver, returns
> DATE columns as java.sql.Date valuess. That surprised me, because the
> ResultSetMetaData claims the column's Java type is java.sql.Timestamp
> -- which would make more sense since DATE columns contain date *and*
> time information, just just date.
> I seem to remember that Oracle 8i did return java.sql.Timestamp for
> DATE columns.
> Did they change this, or am I just misremembering? Is there a way to
> get the driver to return java.sql.Timestamp?
Hi. Oracle made a mistake (in my opinion) in this regard. They made a new DBMS column type 'TIMESTAMP' which is semantically the same as DATE, except it has more precision. The driver now maps that column to a java.sql.TIMESTAMP, but Oracle incorrectly demoted it's map of the DATE column to a java.sql.Date, which loses data by default if you do a getObject. This is as if they made a new 'SUPERNUMBER' column that could hold 50 decimal digits, and then demoted their NUMBER column map to an integer.
Enough rant. You can get the previous mapping by adding this property to your connection:
prop.put ("oracle.jdbc.V8Compatible", "true");
and you should be safely "back in Kansas". Let me know...
Joe Weinstein at BEA Systems Received on Wed Nov 09 2005 - 14:00:28 CST
![]() |
![]() |