File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes about database connectivity Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "about database connectivity" Watch "about database connectivity" New topic

about database connectivity

phani bhushan reddy

Joined: Jul 20, 2007
Posts: 27

I am having problem when i was try to connect the database, while using servlets. It was throwing an exception called ClassNotFoundException, actually i know the meaning of the exception but it was working when i am doing simple applications and also in the swing applications but it was making problem when it comes to servlets only, please tell me the solution for this
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42959
You didn't mention which class was not found -the exception should tell you that- but I'm guessing that it is the JDBC driver. Did you put the jar file that contains the driver into the WEB-INF/lib directory of your web application?
mohan kumar r
Ranch Hand

Joined: Jan 19, 2006
Posts: 38
you can also add jar in CLASSPATH entry of the server you are using.
for example,if you are using weblogic server and Oracel DB,
add classes12.jar to CLASSPATH entry in driver:\bea\user_projects\domains\mydomain\startManagedWebLogic.cmd(or .sh if it is in unix).
restart the server
deploy the application

Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Tomcat ignores the CLASSPATH environment variable.
You might want to check this for more information related to Tomcat's classloading hierarchy.

As Ulf said , you have to put the driver classes jar in WEB-INF/lib folder.

Rahul Bhattacharjee
LinkedIn - Blog
subject: about database connectivity
It's not a secret anymore!