Java 无法加载 JDBC 驱动程序类 'com.mysql.jdbc.Driver' Tomcat 8 & Eclipse
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36118069/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cannot load JDBC driver class 'com.mysql.jdbc.Driver' Tomcat 8 & Eclipse
提问by Moe
Using tomcat 8 with Eclipse Cannot load JDBC driver class 'com.mysql.jdbc.Driver' ::: I have added mysql connecter every where and I still can't connect.
在 Eclipse 中使用 tomcat 8 无法加载 JDBC 驱动程序类 'com.mysql.jdbc.Driver' ::: 我在每个地方都添加了 mysql 连接器,但仍然无法连接。
WEB-INF/lib/
Java Resources/Libraries/
tomcat/lib/ // however I don't see the jar file in my project
web.xml
网页.xml
Tomcat Context.xml
Tomcat 上下文.xml
采纳答案by josivan
You need to add the mysql jar in classpath of Run Configurations.
您需要在运行配置的类路径中添加 mysql jar。
To do this choose menu Run > Run Configuration > Select your Tomcat Installation and the classpath tab. Click on button Add External JARs...
为此,请选择菜单 Run > Run Configuration > Select your Tomcat Installation 和 classpath 选项卡。单击按钮添加外部 JAR...
回答by khaja firoz
Give Right click on project
右键单击项目
- go to properties
- click on java build path
- take add external jars
- choose mysql connector from zip file
- at last click apply and ok .
- 去属性
- 点击java构建路径
- 采取添加外部罐子
- 从 zip 文件中选择 mysql 连接器
- 最后点击应用并确定。
回答by user3008410
Another thing you can try that worked for me is to add the mysql connector jar directly to the folder. Of course change to your environment.
您可以尝试对我有用的另一件事是将 mysql 连接器 jar 直接添加到文件夹中。当然改变你的环境。
C:[YOUR PATH]\apache-tomcat-8.5.24\lib
C:[你的路径]\apache-tomcat-8.5.24\lib
mysql-connector-java-5.1.45.jar
mysql-connector-java-5.1.45.jar
回答by Iskren P.
In my case I fixed this issue as it was happening with tomcat7 7.0.56 on debian 8.11 and apparently this tomcat7 version has some beef with this debian. When I downgraded to tomcat7 7.0.28 this error got fixed since jar was everywhere and only tomcat7 could have been the reason for not getting loaded. I hope this helps someone else save the time that I lost debugging this one
就我而言,我修复了这个问题,因为它在 debian 8.11 上的 tomcat7 7.0.56 上发生,显然这个 tomcat7 版本对这个 debian 有一些影响。当我降级到 tomcat7 7.0.28 时,这个错误得到了修复,因为 jar 无处不在,只有 tomcat7 可能是没有加载的原因。我希望这可以帮助其他人节省我在调试这个时丢失的时间
回答by Daniel C
This comment is posted up and is fine but between steaps 2 and 3 you have to do step 2.50. You just forgot to import jar files into project path.
此评论已发布并且很好,但在第 2 步和第 3 步之间,您必须执行第 2.50 步。您只是忘记将 jar 文件导入到项目路径中。
Give Right click on project
右键单击项目
- go to
properties
- click on java build path
2.50In the right under Java Build Patch click
Library
- take add external jars
- choose
mysql connector
from zip file - at last click apply and ok.
- 去
properties
- 单击 java build path
2.50在 Java Build Patch 下的右侧单击
Library
- 采取添加外部罐子
mysql connector
从 zip 文件中选择- 最后点击应用就OK了。