The moose likes JDBC and the fly likes Unable Connect from servlet-jdbc to Oracle Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JDBC
Reply Bookmark "Unable Connect from servlet-jdbc to Oracle" Watch "Unable Connect from servlet-jdbc to Oracle" New topic
Author

Unable Connect from servlet-jdbc to Oracle

kris iyer
Greenhorn

Joined: Mar 27, 2002
Posts: 5
Hi all
I am using j2ee server and oracle database, i wrote a servlet to connect to oracle database using jdbc(type 4 drivers)
But when i run the servlet thru my browser I get the following error
Exception Report:
javax.servlet.ServletException: JDBC Driver not found.
Root Cause:
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver

I feel that it's not getting the jdbc location....
I even wrote another small program to check if jdbc works and it's working
Therefore I am confused why is it not working
can anyone tell me why is it working ? and is it necessary to do someother settings
thanks

kris
Mahesh Mamani
Ranch Hand

Joined: Jun 25, 2001
Posts: 110
Hi,
Have u checked the value of Path variable in the J2EE server??? Check it and try again...Some problem in Ur environment settings itself...
Try it...

Mahesh
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

There is a slight complication with Oracle in regards to many application servers.
App servers (or servlet containers) like to load the libraries on their own (rather than relying on the classpath) since it allows them to create and manage application contexts so that they aren't all running off the same code-base.
They do this by detecting and loading all of the jars in certain locations (eg .../server/lib and .../common/lib and .../webapps/[ app_context ]/web-inf/lib in Tomcat 4)
The problem with Oracle is that the code is provided as a .zip and not as a .jar
The two are generally compatable, but it can't be found by the application because it doesn't end with .jar
The simplest solution is to rename the file (eg classes111.zip) to be a .jar then drop in the right place for the app server to find...
Dave


[ JavaRanch FAQ ][ Book Promotions ][ DbTamer ][ BumperStickers ][ JavaRanch Badges ]
kris iyer
Greenhorn

Joined: Mar 27, 2002
Posts: 5
Hi Mahesh/dave
Thanks guys for ur help...I was able to run my servlet , David i changed my .zip to .jar but again it was giving the same error then i changed the J2EE_CLASSPATH in userconfig.bat and ran it before my J2EE server....then it was able to find the jdbc path and i was able to connect to database
I had a small doubt ...is it necessary to run userconfig.bat file everytime or does it run automatically (that's when i start j2ee server)?
thanks

kris
 
 
subject: Unable Connect from servlet-jdbc to Oracle
 
Threads others viewed
FOR HELP: Failed to connect to oracle in servlet
Doubt on Servlet having database connection?
JDBC
FOR HELP, can not connect to Oracle using JDBC in servlet.
error finding package when compiling
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com