user1885127
user1885127

Reputation: 39

Not able to connect the DB from Servlet

I have started jsp servlet application with Xampp Server, In which I have dbconnection.java and LoginValidator.java (servlet) files.

I'm getting an error while trying to access the database from servlet (LoginValidator.java).

It is getting the following error:

Class Not found Exception : com.mysql.jdbc.Driver

I have imported the mysql-connector-java-5.1.18-bin.jar. I have searched a lot but could not find the solution.

Upvotes: 3

Views: 172

Answers (3)

jagr
jagr

Reputation: 339

Where the mysql-connector-java-5.1.18-bin.jar is in your project? And is mysql-connector-java-5.1.18-bin.jar in classpath project?

See in you application on server if mysql-connector-java-5.1.18-bin.jar is deployed.

Upvotes: 1

zacheusz
zacheusz

Reputation: 8842

try to put your connector jar into /WEB-INF/lib/ directory of your application. If it doesn't work then try this ugly trick: put your mysql-connector jar into \xampp\tomcat\lib\ directory. You may have incorrectly imported connector jar so it is not on the classpath.

Upvotes: 0

Abubakkar
Abubakkar

Reputation: 15644

You have to put mysql-connector-java-5.1.18-bin.jar file inside the folder:

YOUR_WEBAPPS_FOLDER/YOUR_WEBAPP/WEB-INF/lib/

so that it will be available in the classpath when your servlet is compiled by the web container.

Upvotes: 0

Related Questions