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 to 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, 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));
case Types.TIMESTAMP:
map.put(name, resultSet.getTimestamp(i));
You will also get a java.sql.Timestamp instead of a, 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.

active directory applied formal logic ashurbanipal authentication books c c++ comics conference continuations coq data structure digital humanities Dijkstra eclipse virgo electronics emacs goodreads haskell http java job Knuth ldap link linux lisp math naming nimrod notation OpenAM osgi parsing pony programming language protocols python quote quotes R random REST ruby rust SAML scala scheme shell software development system administration theory tip toy problems unix vmware yeti
Member of The Internet Defense League
Site proudly generated by Hakyll.