Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 

enter image description here

enter image description here

web.xml

enter image description here

Tomcat Context.xml

enter image description here

like image 523
Moe Avatar asked Mar 20 '16 18:03

Moe


People also ask

How do I know if MySQL JDBC driver is installed?

You can determine the version of the JDBC driver that you installed, by calling the getDriverVersion method of the OracleDatabaseMetaData class. You can also determine the version of the JDBC driver by executing the following commands: java -jar ojdbc5. jar.

Which exception is raised when JDBC driver failed to load?

Answer: SQLException occurs if there is an error in the database access or other errors related to the database. When SQLException occurs, an object of type SQLException will be passed to the catch clause.

Which JDBC driver is used for MySQL?

Driver in MySQL Connector/J is com. mysql. cj. jdbc.

Where is the JDBC driver located MySQL?

The configuration file is located in the MySQL program data directory (for example: C:\ProgramData\MySQL\MySQL Server 5.6 on Windows or /etc/mysql/ on Linux.


2 Answers

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

Run Configuration

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

like image 178
josivan Avatar answered Sep 18 '22 19:09

josivan


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

like image 32
user3008410 Avatar answered Sep 19 '22 19:09

user3008410