-1

为什么我会收到以下异常?

JDBC Driver class not found: com.microsoft.jdbc.sqlserver.SQLServerDriver
java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1688)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1533)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:123)
    at org.hibernate.connection.DriverManagerConnectionProvider.configure(DriverManagerConnectionProvider.java:84)
    at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:137)
    at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:79)
    at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:448)
    at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:89)
    at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2101)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1325)
    at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
    at com.nursary.util.HibernateUtil.buildSessionFactory(HibernateUtil.java:13)
    at com.nursary.util.HibernateUtil.<clinit>(HibernateUtil.java:8)
    at com.nursary.action.NursaryAction.<init>(NursaryAction.java:53)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.lang.Class.newInstance0(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:119)
    at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:150)
    at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:139)
    at com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:109)
    at com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:287)
    at com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:387)
    at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:186)
    at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
    at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
    at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:47)
    at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:458)
    at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:298)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
4

2 回答 2

2

也许你是新手Java
我认为您需要在http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=11774下载 JDBC 驱动程序。之后解压缩下载的文件以获取.jar文件。最后复制sqljdbc.jarsqljdbc4.jar到您的类路径以修复错误。

于 2013-06-12T20:13:59.460 回答
1

该类com.microsoft.jdbc.sqlserver.SQLServerDriver不在您的 JRE 类路径中。

它位于sqljdbc.jar文件中,应该添加到您的类路径中。

于 2013-06-12T20:03:02.980 回答