java SQL Server JDBC 异常

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2212037/
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-10-29 20:03:53  来源:igfitidea点击:

SQL Server JDBC Exception

javasqlsql-serverjdbcjakarta-ee

提问by Evan Klein

When using ANT to build my Java application I keep getting this error. I have tried multiple times to use SQLJDBC.JAR and SQLJDBC4.JAR but continually receive this error message. I am completely stumpped why this error is received even after upgrading to sqljdbc4.jar.

使用 ANT 构建我的 Java 应用程序时,我不断收到此错误。我曾多次尝试使用 SQLJDBC.JAR 和 SQLJDBC4.JAR,但不断收到此错误消息。我完全不明白为什么即使在升级到 sqljdbc4.jar 后仍会收到此错误。

[javadoc] java.lang.UnsupportedOperationException: 
    Java Runtime Environment (JRE) version 1.6 is not supported by this driver.
    Use the sqljdbc4.jar class library, which provides support for JDBC 4.0.

采纳答案by dcp

Refer to this link: http://msdn.microsoft.com/en-us/library/ms378526.aspx

请参阅此链接:http: //msdn.microsoft.com/en-us/library/ms378526.aspx

"sqljdbc4.jar class library requires a Java Runtime Environment (JRE) of version 6.0 or later."

“sqljdbc4.jar 类库需要 6.0 或更高版本的 Java 运行时环境 (JRE)。”

So if you aren't using a JDK 1.6 or later when compiling, you will get an error when using sqljdbc4.jar.

因此,如果您在编译时未使用 JDK 1.6 或更高版本,则在使用 sqljdbc4.jar 时会出现错误。

If you are using JDK 1.5 or earlier, then you need to be using the sqljdbc.jar, which you can get from here.

如果您使用的是 JDK 1.5 或更早版本,那么您需要使用 sqljdbc.jar,您可以从这里获得。

Also, one tip with ANT is that you can use "ant -verbose" to help determine which libaries it's finding on the classpath to make sure it's using the sqljdbc JAR you expect. Also, make sure to confirm which version of the JDK you are compiling with. You can set the JAVA_HOME environment variable to point to a different JDK to compile with.

此外,ANT 的一个技巧是您可以使用“ant -verbose”来帮助确定它在类路径上找到哪些库,以确保它使用您期望的 sqljdbc JAR。另外,请确保确认您正在编译的 JDK 版本。您可以将 JAVA_HOME 环境变量设置为指向不同的 JDK 进行编译。