How to compile JDBC 3.0 compatible sources with JDK 1.6?

I need to compile an old library written for JDBC 3.0 with 1.6 JDK (which contains JDBC 4.0). This is not possible because the new JDBC interfaces contain Blob and Clob-related methods, so classes that implement them cannot compile. Implementing new methods in the library is not an option.

Can this be done with JDK 1.6, or do I need to install 1.5 JDK?

+4
source share
1 answer

You do not need to install JDK1.5, but you will need Java 5 rt.jar and specify it in the compiler bootclasspath:

 javac -source 1.5 -target 1.5 -bootclasspath /path/to/jre5/lib/rt.jar 

Otherwise, you will compile with Java6 rt.jar , which contains JDBC 4 interfaces, and then the compiler will complain about unimplemented methods. Using the already compiled JDBC 3.0 library will work fine under Java 6 to such an extent that the method added to JDBC 4 is called.

+3
source

All Articles