SQL Server JDBC异常 [英] SQL Server JDBC Exception

查看:165
本文介绍了SQL Server JDBC异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用ANT构建我的Java应用程序时,我不断收到此错误。我已多次尝试使用SQLJDBC.JAR和SQLJDBC4.JAR但不断收到此错误消息。即使在升级到sqljdbc4.jar之后,我也完全没收到这个错误。

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.


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


推荐答案

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

sqljdbc4.jar类库需要6.0或更高版本的Java Runtime Environment(JRE)。

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

所以如果你在编译时没有使用JDK 1.6或更高版本,使用sqljdbc4.jar时会出错。

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.5或更早版本,那么您需要使用sqljdbc.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.

另外,ANT的一个提示是你可以使用ant -verbose来帮助确定它是哪个库在类路径上查找以确保它使用您期望的sqljdbc JAR。此外,请确保确认要编译的JDK版本。您可以将JAVA_HOME环境变量设置为指向要编译的其他JDK。

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.

这篇关于SQL Server JDBC异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆