gpt4 book ai didi

mysql - 无法使用 java servlet 的 jdbc 驱动程序使用 apache 服务器 v7.0 连接 mysql 5.5 甚至 5.1.22

转载 作者:行者123 更新时间:2023-11-30 23:25:59 26 4
gpt4 key购买 nike

我正在尝试为 mysql 使用 jdbc 驱动程序。但是找不到驱动程序并在 eclipse 中给出以下错误。(我在本地主机上使用 Tomcat v7.0)

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。我无法理解另一个..是否有任何其他方法可以解决此问题或向我推荐上述任何过程。由于我是网络新手,能否请您帮助详细说明您的建议。

提前谢谢大家。

最佳答案

你有没有用类似的东西初始化/加载驱动程序:

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

在调用 DriveManager.getConnection(...) 之前

关于mysql - 无法使用 java servlet 的 jdbc 驱动程序使用 apache 服务器 v7.0 连接 mysql 5.5 甚至 5.1.22,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13331551/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com