• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servlet not working

 
phani bhushan reddy
Greenhorn
Posts: 27
Eclipse IDE Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When i was try to connect to database doing servlets, it was throwing an exception called ClassNotFoundException, but i actually know the meaning of this but the jdbc connectivity is working the general and swing programs, but it was throwing an exception while using servlets, please tell me the solution, I am using Tomcat5.5
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tomcat does NOT use your system environment variables such as classpath to locate a database. You must configure Tomcat with specific database information. I am sure this is all covered in the tomcat-doc section of a typical Tomcat installation.

Bill
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As William said , the classpaht is ignored by Tomcat. So where are you putting the driver classes jar.In case of web applications it should be within WEB-INF/lib folder.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rahul Bhattacharjee:
As William said , the classpaht is ignored by Tomcat. So where are you putting the driver classes jar.In case of web applications it should be within WEB-INF/lib folder.


This assumes that the original poster is using forName to find the driver which is probably a good assumption since he mentioned that the same code works in a Swing app.

A better approach for getting connection for a web application is to use container managed connection pooling.
See:
http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
to learn how to set this up for the container you're using.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic