Java 如何检查特定驱动程序实现的 JDBC API 版本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18887033/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 11:55:10  来源:igfitidea点击:

How to check which JDBC API version a specific driver implements

javajdbc

提问by Surendran Duraisamy

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

如何检查我使用的 JDBC 驱动程序的类型是什么?

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

我目前正在使用ojdbc14.jar. 如何检查我的驱动程序是否符合 JDBC 4 驱动程序?

回答by Adrian B.

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.jarand read the META-INF/MANIFEST.MFfile.

每个 JAR 文件都应该有一个清单文件,其中包含有关打包在 JAR 文件中的文件的信息。要查看它,请解压缩ojdbc14.jar并阅读META-INF/MANIFEST.MF文件。

As far as I know ojdbc14.jardoes not support JDBC4. To make sure what you version supports check out what Oracleis saying.

据我所知ojdbc14.jar不支持 JDBC4。要确保您的版本支持,请查看Oracle所说的内容。

回答by Elf

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

您可以运行以下命令来获取驱动程序版本。

java -jar ojdbc14.jar

This gave me o/p as:

这给了我 o/p 为:

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.

所以驱动版本是11.1.0.7.0,是JDBC 3.0投诉。

回答by YourAboutMeIsBlank

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).

JDBC 驱动程序通常位于安装目录的 WL_HOME/server/lib 位置。该文件是 ojdbc7.jar 或 ojdbc6.jar(对于 WLS 的新版本)或 ojdbc14.jar(对于 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

  • 检查 JDBC 驱动程序版本的一种方法是打开 ojdbc jar 文件并进入 META-INF 文件夹,然后打开“MANIFEST.MF”文件。版本可以在“Specification-Version”旁边看到。

  • 另一种方法是在前面提到的位置运行以下命令:

    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.

请注意,您必须使用适用于您正在运行的 JDK 版本的 JDBC JAR 文件。例如,“ojdbc5.jar”旨在用于 JDK 1.5。因此,如果您使用 JDBC 驱动程序 JAR 文件“ojdbc6.jar”运行 JDK 1.5,那么在执行此检查时将抛出“java.lang.UnsupportedClassVersionError: Bad version number in .class file”错误消息。

回答by Joachim Sauer

The DatabaseMetaDataclass provides getJDBCMajorVersionand getJDBCMinorVersionwhich should return the JDBC version that the driver aims to implement.

DatabaseMetaData类提供getJDBCMajorVersiongetJDBCMinorVersion它应该会返回JDBC版本驱动程序的目标来实现。

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

请注意,报告特定 JDBC 版本并不一定意味着该(和更早)版本的每个功能都已完全实现。

回答by Basil Bourque

getJDBCMajorVersion& getJDBCMinorVersion

getJDBCMajorVersion& getJDBCMinorVersion

You can interrogate your JDBC driver at runtime.

您可以在运行时询问您的 JDBC 驱动程序。

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. 调用这两个方法以获取此驱动程序声称支持的 JDBC 规范的主要和次要版本:

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

请记住,特定驱动程序可能不支持该版本 JDBC API 的所有功能。