How to check which JDBC API version a specific dri

2020-03-01 18:57发布

问题:

How can I check whatthe type of the JDBC driver I am using is?

I am currently using ojdbc14.jar. How can I check if my driver is JDBC 4 compliant driver?

回答1:

You can run the following command to get the driver version.

java -jar ojdbc14.jar

This gave me o/p as:

Oracle 11.1.0.7.0-Production JDBC 3.0 compiled with JDK5

So the driver version is 11.1.0.7.0 and it is JDBC 3.0 complaint.



回答2:

Every JAR file should have a manifest file which contains information about the files packaged in the JAR file. To check it out, unzip the ojdbc14.jar and read the META-INF/MANIFEST.MF file.

As far as I know ojdbc14.jar does not support JDBC4. To make sure what you version supports check out what Oracle is saying.



回答3:

getJDBCMajorVersion & getJDBCMinorVersion

You can interrogate your JDBC driver at runtime.

Retrieve a DatabaseMetaData. Call the two methods to get the major and minor versions of the JDBC specification for which this driver claims support:

  • DatabaseMetaData::getJDBCMajorVersion
  • DatabaseMetaData::getJDBCMinorVersion

Keep in mind that a particular driver may not support every feature of that version of JDBC API.



回答4:

The DatabaseMetaData class provides getJDBCMajorVersion and getJDBCMinorVersion which should return the JDBC version that the driver aims to implement.

Note that reporting a specific JDBC version does not necessarily imply that every feature of that (and earlier) versions is fully implemented.



回答5:

From this LINK

The JDBC driver is typically located at the location WL_HOME/server/lib of the installation directory. The file is ojdbc7.jar or ojdbc6.jar (for new versions of WLS), or ojdbc14.jar (for older versions of WLS).

  • One way to check the JDBC driver version is to open the ojdbc jar file and go inside the META-INF folder, and then open the "MANIFEST.MF" file. The version can be seen next to "Specification-Version".

  • Another way is to run the command below on the location mentioned previously:

    java -jar ojdbc6.jar -getversion

Note that you must use the JDBC JAR file intended for the version of the JDK that you are running. For example, "ojdbc5.jar" is intended for use with JDK 1.5. So if you run JDK 1.5 with the JDBC driver JAR file "ojdbc6.jar" then a "java.lang.UnsupportedClassVersionError: Bad version number in .class file" error message will be thrown when performing this check.