Java 6 comes with JDBC 4, which is not backward compatible with JDBC shipped with previous versions of Java.
We have a JDBC driver which must support both Java 5 and Java 6. If I implement the new interfaces in the driver, it doesn't work in Java 5 because the interfaces also uses new classes. So we have 2 versions of the driver. Is there a way to have one jar for both Java 5 and 6?
If you implement a JDBC 3.0 driver, and your clients run it in Java 6, they'll get errors if they call any of the new JDBC 4.0 methods. This is rare, as those new methods aren't used very often, but if you want to be fool-proof, the below solution (which is a hack) should do the trick:
We can discard the JDBC 4.0 interfaces jar because:
The only potential problem could be with the java 5 classloader. It may fail if it can't find the new JDBC 4.0 interfaces (like java.sql.NClob). I don't think this will happen in the Sun JVM unless you call a method which returns one of those new interfaces, so you should be good. If I'm wrong and this is an issue, just put the discarded jar (the one that defined the new JDBC 4.0 interfaces) on your classpath when running in Java 5.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With