简体   繁体   English

无法加载JDBC驱动程序类'com.mysql.jdbc.Driver'Tomcat 8和Eclipse

[英]Cannot load JDBC driver class 'com.mysql.jdbc.Driver' Tomcat 8 & Eclipse

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. 使用tomcat 8与Eclipse无法加载JDBC驱动程序类'com.mysql.jdbc.Driver':::我已经添加了mysql connecter每个地方我仍然无法连接。

WEB-INF/lib/
Java Resources/Libraries/
tomcat/lib/  // however I don't see the jar file in my project 

在此输入图像描述

在此输入图像描述

web.xml web.xml中

在此输入图像描述

Tomcat Context.xml Tomcat Context.xml

在此输入图像描述

You need to add the mysql jar in classpath of Run Configurations. 您需要在Run Configurations的类路径中添加mysql jar。

运行配置

To do this choose menu Run > Run Configuration > Select your Tomcat Installation and the classpath tab. 要执行此操作,请选择菜单“运行”>“运行配置”>“选择Tomcat安装”和“类路径”选项卡。 Click on button Add External JARs... 点击按钮添加外部JAR ...

Give Right click on project 右键单击项目

  1. go to properties 去物业
  2. click on java build path 单击java构建路径
  3. take add external jars 加上外部罐子
  4. choose mysql connector from zip file 从zip文件中选择mysql连接器
  5. at last click apply and ok . 最后点击申请,然后确定。

Another thing you can try that worked for me is to add the mysql connector jar directly to the folder. 您可以尝试的另一件事对我来说是将mysql连接器jar直接添加到该文件夹​​。 Of course change to your environment. 当然会改变你的环境。

C:[YOUR PATH]\\apache-tomcat-8.5.24\\lib C:[你的路径] \\ apache-tomcat-8.5.24 \\ lib

mysql-connector-java-5.1.45.jar MySQL的连接器的Java-5.1.45.jar

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. 在我的情况下,我解决了这个问题,因为它发生在debian 8.11上的tomcat7 7.0.56,显然这个tomcat7版本与这个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. 当我降级到tomcat7 7.0.28时,这个错误得到了解决,因为jar无处不在,只有tomcat7可能是没有加载的原因。 I hope this helps someone else save the time that I lost debugging this one 我希望这可以帮助别人节省我失去调试这个的时间

This comment is posted up and is fine but between steaps 2 and 3 you have to do step 2.50. 这个评论已张贴,并且没有问题,但是在第2和第3阶段之间你必须执行步骤2.50。 You just forgot to import jar files into project path. 您只是忘了将jar文件导入项目路径。

Give Right click on project 右键单击项目

  1. go to properties properties
  2. click on java build path 2.50 In the right under Java Build Patch click Library 单击java build path 2.50在Java Build Patch的右侧单击Library
  3. take add external jars 加上外部罐子
  4. choose mysql connector from zip file 从zip文件中选择mysql connector
  5. at last click apply and ok. 最后点击申请,然后确定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM