2015-04-08 202 views
0

異常跟蹤:org.hibernate.exception.JDBCConnectionException:無法打開連接

org.hibernate.exception.JDBCConnectionException: Cannot open connection 
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:99) 
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) 
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52) 
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:449) 
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167) 
at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:160) 
at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:81) 
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1473) 
at com.jwt.hibernate.dao.UserDAO.addUserDetails(UserDAO.java:27) 
at com.jwt.hibernate.controller.UserControllerServlet.doPost(UserControllerServlet.java:29) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:646) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) 
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) 
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) 
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) 
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504) 
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170) 
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) 
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950) 
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) 
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421) 
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1074) 
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611) 
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 
at java.lang.Thread.run(Thread.java:745) 
Caused by: java.sql.SQLException: No suitable driver found for jdbc:sqlserver://localhost:1433;databaseName=sagar 
at java.sql.DriverManager.getConnection(DriverManager.java:689) 
at java.sql.DriverManager.getConnection(DriverManager.java:208) 
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:133) 
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446) 
... 28 more 
+1

你的問題是什麼? –

回答

0
No suitable driver found for jdbc:sqlserver://localhost:1433;databaseName=sagar 

從你的例外,我看到你沒有在你的類路徑JDBC驅動程序的jar。下載SQL JDBC jar並將其放置在你的類路徑中。

0

,而你的問題(或缺乏)被認爲是目前還不清楚,我會盡力幫助:

如果你是在本地環境中開發,你應該下載JDBC驅動程序罐子,在你的類路徑添加它。

如果您正在開發遠程服務器環境,除了將驅動程序添加到類路徑之外,還應將驅動程序放在項目的WebContent/Web-Inf/bin /文件夾中。

這些步驟後,你應該能夠克服這個例外。 祝你好運。