Can I make jdbc 4.1 source level compatible with jdk 1.6?

I have code that extends java.sql.Statement, java.sql.Connection and java.sql.DataSource.

My compatibility goal is java 1.6, I don't want to use any specific functions introduced by JDBC 4.1 in jdk 1.7.

But jdk, which is installed by default on my system, is Openjdk 7. I would like to stick with this, but I still want my code to target 1.6.

In Eclipse, I set 1.6 as my target for compilation, but jdk insists that I implement new methods in the java.sql classes ... I created stubs that do nothing but throw an UnsupportedOperationException. So here are my questions:

  • Is there any solution to compile source code 1.6 with 1.7 sdk?
  • If not, is my choice of "implementing" new methods safe for UnsupportedOperationException if I don't use the specific features of jdbc 4.1?
  • is there a connection pool that implements jdbc 4.1?
+4
source share
1 answer

JDBC4.0 is for JDK1.6, and you should use conditional compilation to create a package compatible with JDBC4.0.

0
source

Source: https://habr.com/ru/post/1435647/


All Articles