Mohit Bhardwaj
Mohit Bhardwaj

Reputation: 23

Unable to execute .jsp files getting an error java.lang.classNotFoundException:com.mysql.jdbc.driver

I tried to execute a wab page with the help of JSP & mysql as a database. After execution of first web pages it never shows the credential which is eneterd in the login page. In tomcat logs it gives the error of "java.lang.classNotFoundException:com.mysql.jdbc.driver"

Download a mysqlconnector into the below path: "D:\mohit\mysql-connector-java-5.1.23"

I have entered a CLASS PATH in system Environmental variables as D:\mohit\mysql-connector-java-5.1.23\mysql-connector-java-5.1.23-bin.jar

Local system java is installed at C:\Program Files\Java\jre1.6.0_17

Please let me know how can I overcome from this problem?

Upvotes: 1

Views: 4083

Answers (3)

Hardik Mishra
Hardik Mishra

Reputation: 14887

you need to have a JAR file somewhere containing com.mysql.jdbc.Driver class (so called JDBC driver). This JAR needs to be visible in Tomcat. So, I would suggest to place mysql-jdbc.jar at physical location to /WEB-INF/lib directory of your project.

Many times ClassNotFoundException occurs if jar is not at physical location. Do not play with Classpath if you are not sure. It is always suggested to put external "Jars" under /WEB-INF/lib directory and restart Tomcat, It takes care the rest.

Upvotes: 1

Prakash K
Prakash K

Reputation: 11698

Put the mysql-connector jar inside tomcat/lib/ext folder and restart tomcat.

Upvotes: 1

Abdullah Shaikh
Abdullah Shaikh

Reputation: 2604

I guess you are running the application on server from eclipse itself, the jar is not getting pushed to server. Try placing the jar file in WEB-INF/lib folder

Upvotes: 0

Related Questions