# Oracle JDBC API changes: things that make me sigh

Posted on October 28, 2011 by Tommy McGuire
Labels: software development, java

For reasons that escape me at the moment (something about support from Oracle, I think), we are having to upgrade the Oracle JDBC driver from 10.2.0.4 to 11.2.0.3. Ideally, this would be a simple, transparent change. But it isn't.

A co-worker quickly found an issue with the driver's handling of java.sql.Date and java.sql.Timestamp. Specifically, the previous driver would map SQL DATE columns to java.sql.Date, while the current driver maps SQL DATE columns to java.sql.Timestamp. The details are described by the Oracle JDBC faq, What is going on with DATE and TIMESTAMP? (Note: that entry describes the previous, 10.2.0.4 behavior as the "problem".)

The bottom line is that if you use resultSet.getObject(i) then for a DATE column you will now get a java.sql.Timestamp object where you would previously get a java.sql.Date object. Also, if you use code like

      switch (metaData.getColumnType(i))      {      case Types.DATE:        map.put(name, resultSet.getDate(i));        break;      case Types.TIMESTAMP:        map.put(name, resultSet.getTimestamp(i));        break;      ...
You will also get a java.sql.Timestamp instead of a java.sql.date, since the java.sql.Types mapping has changed as well.

Now, I don't know whether or not this is the Right Thing To Do. I don't actually care either way. But the change, even to fix a problem, just makes me want to sob quietly.

And the Java standard library's API is just as wacky as ever.

Site proudly generated by Hakyll.