本文介绍了无法加载com.microsoft.sqlserver.jdbc.SQLServerDriver类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试连接到SQL Server 2008数据库时遇到问题,这是一个完整的例外:
I'm having an issue while trying to connect to an SQL Server 2008 database, here is the complete exception :
java.lang.UnsupportedClassVersionError: Bad version number in .class file (unable to load class com.microsoft.sqlserver.jdbc.SQLServerDriver)
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2531)
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1010)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1483)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361)
java.lang.ClassLoader.loadClassInternal(Unknown Source)
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Unknown Source)
ma.ancfcc.dao.ConnexionSigest.getConnection(ConnexionSigest.java:120)
ma.ancfcc.action.VerifyLoginAction.execute(VerifyLoginAction.java:70)
org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:305)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
异常指向此行代码:
private static String DRIVER_SQLSERVER="com.microsoft.sqlserver.jdbc.SQLServerDriver";
我该如何解决?
推荐答案
当您尝试加载使用比运行应用程序的Java版本更高的Java版本编译的类时,会引发此异常.
This exception is thrown when you try to load a class that was compiled with higher version of Java than the one you are running your application with.
请参见 UnsupportedClassVersionError
- 使用
java -version
检查运行应用程序的JVM的版本 - 按照-使用
javap -verbose com.microsoft.sqlserver.jdbc.SQLServerDriver
- 如果jar打算与更高版本的Java一起使用,则可以:
- 使用更高版本的JVM来运行应用程序
- 下载旧版驱动程序
- check the version of JVM you run your app with using
java -version
- check the version of class file as suggested in how to check the jdk version used to compile a .class file - using
javap -verbose com.microsoft.sqlserver.jdbc.SQLServerDriver
- If jar is intended to use with higher version of Java, you can either:
- use higher version of JVM to run the app
- download older version of driver
这篇关于无法加载com.microsoft.sqlserver.jdbc.SQLServerDriver类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!