2012-11-11 18 views
1

我想爲mysql使用jdbc驅動程序。但司機未發現,並給出在eclipse下面的錯誤。(我使用本地主機的Tomcat V7.0)不能使用jdbc驅動程序的Java Servlet使用Apache服務器v7.0來連接mysql 5.5甚至5.1.22

java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3307/mydata[Ljava.lang.StackTraceElement;@50aaaf66 
at java.sql.DriverManager.getConnection(Unknown Source) 
at java.sql.DriverManager.getConnection(Unknown Source) 
at AddStudent.doPost(AddStudent.java:52) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) 
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225) 
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) 
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:927) 
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:1001) 
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585) 
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
at java.lang.Thread.run(Unknown Source) 

我身邊有搜索文檔,並得到這個..

In general, follow the installation instructions that come with your version of Tomcat, as the way you configure datasources in Tomcat changes from time to time, and if you use the wrong syntax in your XML file, you will most likely end up with an exception similar to the following:

Error: java.sql.SQLException: Cannot load JDBC driver class 'null ' SQL state: null

Note that the auto-loading of drivers having the META-INF/service/java.sql.Driverclass in JDBC 4.0 causes an improper undeployment of the Connector/J driver in Tomcat on Windows. Namely, the Connector/J jar remains locked. This is an initialization problem that is not related to the driver. The possible workarounds, if viable, are as follows: use "antiResourceLocking=true" as a Tomcat Context attribute, or remove the META-INF/directory.

文檔推薦不要使用antiResourceLocking。 我無法理解另一個.. 是否有任何其他方法來解決這個問題或推薦我的任何上述過程。 因爲我是網絡新手,你可以幫助你的建議中的細節。

謝謝大家提前。

+1

您可以編輯您的問題,包括你的'doPost'方法之前

Class.forName("com.mysql.jdbc.Driver").newInstance(); 

?我關心'jdbc:mysql:// localhost:3307/mydata [Ljava.lang.StackTraceElement; @ 50aaaf66'位:我不知道你是如何設法添加一個StackTraceElement數組的你的連接字符串。另外,你的Web應用的'lib'文件夾中是否有MySQL連接器JAR? –

+1

該部分是由於該行在catch塊 System.out.println(sqle.getStackTrace()); 對不起,我也粘貼了。 –

回答

0

你初始化/加載了驅動程序的東西,如:呼叫DriveManager.getConnection(...)

相關問題