• Post Reply Bookmark Topic Watch Topic
  • New Topic

Database and servlet  RSS feed

 
zohreh talebi
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear friends,

I wrote a servlet that it should work with database.when i deploy my project, it has this excepion:

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver.

I think ,it doesnot load my driver.but i initialize url name , password , driver name in my XML file.and i have a DatabaseManager class that make some setter and getter methods for each of them and produse a connection.In init() method i take the value of each of them from XML file and set .

I don't underestand why it doesn't work?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66149
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where did you place the MySQL jar file?
 
zohreh talebi
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Bear,

I place it in lib folder. but it doesn't anwser.

Thanks for your reply.


Zohreh
 
Bosun Bello
Ranch Hand
Posts: 1512
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's see how the URL and driver class name is defined in the XML.
 
Muhammad Saifuddin
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ClassNotFoundException : com.mysql.jdbc.Drive" means that the CLASSPATH is not set properly..

If you're using an IDE like Eclipse or IntelliJ or NetBeans, you will have to add jars to the CLASSPATH in Project properties.

or If you are using an web Server like Tomcat, you should add jars to the WEB/INF/lib directory in your web context.

hope it helps.
[ January 16, 2007: Message edited by: Saif uddin ]
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by zohreh talebi:
Dear Bear,

I place it in lib folder. but it doesn't anwser.

Thanks for your reply.


Zohreh


Try opening the jar using zip utility and see whether you have the following file com/mysql/jdbc/Driver.class in that.
 
Rao Raghu
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is another driver for mysql as: org.gjt.mm.mysql.Driver

Try using this.If you are using tomcat server, place a copy of the jar in commons/lib also.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!