36

I noticed the following difference but did not see it documented anywhere. I'm wondering if others have noticed the same thing or can point me to some documentations that proves the same.

Env:-

Oracle 11g, JDK 1.6, iBatis, PL/SQL

Scenario:-

ojdbc14.jar: if pl/sql returns a variable of type DATE and I try to put that in a java.sql.Date variable then everything works fine. Example:

Date annualDate = (Date) map.get("exam_date");

ojdbc6.jar: if pl/sql returns a variable of type DATE and I try to put that in a java.sql.Date variable then I get an exception:

java.lang.ClassCastException: java.sql.Timestamp cannot be cast to java.sql.Date
Omnipresent
  • 29,434
  • 47
  • 142
  • 186
  • Can't you call getDate('exam_date') on the result_set, and get a proper date and not a timestamp? – bwawok Jul 09 '10 at 04:16
  • I am experiencing a similar type of issue after upgrading from ojdbc14 to ojdbc6. I would really appreciate if someone could look into this problem and provide me with an answer https://stackoverflow.com/questions/46543694/object-deserialization-failure-in-ojdbc14-to-ojdbc6-upgrade – G 1 Oct 04 '17 at 10:07

4 Answers4

44

The "14" and "6" in those driver names refer to the JVM they were written for. If you're still using JDK 1.4 I'd say you have a serious problem and need to upgrade. JDK 1.4 is long past its useful support life. It didn't even have generics! JDK 6 u21 is the current production standard from Oracle/Sun. I'd recommend switching to it if you haven't already.

duffymo
  • 305,152
  • 44
  • 369
  • 561
28

Actually, ojdbc14.jar doesn't really say anything about the real version of the driver (see JDBC Driver Downloads), except that it predates Oracle 11g. In such situation, you should provide the exact version.

Anyway, I think you'll find some explanation in What is going on with DATE and TIMESTAMP? In short, they changed the behavior in 9.2 drivers and then again in 11.1 drivers.

This might explain the differences you're experiencing (and I suggest using the most recent version i.e. the 11.2 drivers).

Zac Thompson
  • 12,401
  • 45
  • 57
Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
  • Oracle JDBC driver naming is pretty sad as this points out. We've been beyond the 8.3 file name restrictions since forever in Internet time. I've got two different copies of ojdbc14.jar. One with DRIVER_VERSION 10.2.0.2.0 built 2006-Jan-24 and 10.2.0.1.0XE built a day later with many differences in the code. Too bad they aren't named ojdbc-jdk1.4-10.2.0.2.0.jar and ojdbc-jdk1.4-10.2.0.1.0XE.jar (or jdk4 instead of 1.4). – jla Aug 27 '20 at 23:26
10

I have same problem!

Found following in oracle site link text

As mentioned above, the 11.1 drivers by default convert SQL DATE to Timestamp when reading from the database. This always was the right thing to do and the change in 9i was a mistake. The 11.1 drivers have reverted to the correct behavior. Even if you didn't set V8Compatible in your application you shouldn't see any difference in behavior in most cases. You may notice a difference if you use getObject to read a DATE column. The result will be a Timestamp rather than a Date. Since Timestamp is a subclass of Date this generally isn't a problem. Where you might notice a difference is if you relied on the conversion from DATE to Date to truncate the time component or if you do toString on the value. Otherwise the change should be transparent.

If for some reason your app is very sensitive to this change and you simply must have the 9i-10g behavior, there is a connection property you can set. Set mapDateToTimestamp to false and the driver will revert to the default 9i-10g behavior and map DATE to Date.

Aram Arabyan
  • 2,339
  • 1
  • 17
  • 30
1

Also, from ojdbc14 to ojdbc6, several types (e.g., OracleResultSet, OracleStatement) moved from package oracle.jdbc.driver to oracle.jdbc.

Paulo Merson
  • 13,270
  • 8
  • 79
  • 72