Reputation: 49
I try to connect to MySQL database (works perfect when I connect to it without servlet) and get the below error all the time:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
This error means (as I understand) that I don't have some jar files in my project. but this is not true, because I have those Jars. !Moreover, if I realy didn't had those jar, I could not have connected to the database anyway.
What I missed?
Upvotes: 1
Views: 110
Reputation: 1114
By looking at those tags this is a web application. So the error clearly states you don't have your SQL Venders Driver jars in the class path.
You can put this jar in your Project/WEB-INF/lib folder and restart whatever web server you are using. Then you will be good to go.
Upvotes: 2
Reputation: 1
Your mysql jdbc jar driver isn't in your classpath.
If you run it from a servlet, it uses the classpath of your servlet container. This classpath probably contains it.
Find mysql-connector-java where you can, and copy into your classpath.
Upvotes: 1