• Register
Welcome to Kodlogs, programming questions and answer website.
0 votes


I am getting below error while trying to run my JDBC code

exception in thread "main" java.lang.classnotfoundexception: com.mysql.jdbc.driver

code causing issue as below:

     Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/simple",
     Statement stat=conn.createStatement();
     String sqlquery="SELECT * FROM CUST";
by (300 points)  
reopened by

1 Answer

+1 vote
Best answer

Possible Cause: 

It seems your Problem is related to "MySql Jdbc Driver"

Solution :

The "Class.forName("com.mysql.jdbc.Driver");" code is tring to load the driver, but it is not getting it, this is the reason you are getting: exception in thread "main" java.lang.classnotfoundexception: com.mysql.jdbc.driver.

To resolve the error please add the "MySQL jdbc driver jar" file in to your WEB-INF/lib folder from below link



To avoid getting this error please add "MySQL jdbc driver jar" file in to your WEB-INF/lib folder

by (36.1k points)  
selected by