简体   繁体   中英

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.

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

在此输入图像描述

在此输入图像描述

web.xml

在此输入图像描述

Tomcat Context.xml

在此输入图像描述

You need to add the mysql jar in classpath of Run Configurations.

运行配置

To do this choose menu Run > Run Configuration > Select your Tomcat Installation and the classpath tab. Click on button Add External JARs...

Give Right click on project

  1. go to properties
  2. click on java build path
  3. take add external jars
  4. choose mysql connector from zip file
  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. Of course change to your environment.

C:[YOUR PATH]\\apache-tomcat-8.5.24\\lib

mysql-connector-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. 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

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.

Give Right click on project

  1. go to properties
  2. click on java build path 2.50 In the right under Java Build Patch click Library
  3. take add external jars
  4. choose mysql connector from zip file
  5. at last click apply and ok.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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