aspose file tools*
The moose likes Servlets and the fly likes FOR HELP, can not connect to Oracle using JDBC in servlet. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "FOR HELP, can not connect to Oracle using JDBC in servlet." Watch "FOR HELP, can not connect to Oracle using JDBC in servlet." New topic
Author

FOR HELP, can not connect to Oracle using JDBC in servlet.

Chris Ben
Ranch Hand

Joined: Jan 15, 2001
Posts: 135
Hi everyone,
I got pretty frustrated while working on servlet and JDBC recently and hope some experts can help me out.
I am trying to connect to a oracle database using servlet, which is hosted by Tomcat, UNIX server.
I have no right to play with the server so I copy the whole directory of oracle thin driver to my servlet class directory from others, looks like unzipped class12.zip.
I am not sure whether that is the right driver, but I have no problem to connect to the oracle in the stand along application (in main method) in UNIX. However, after I tried to put the same codes in the doGet() of my servlet and call it from the browser, I got error as "No suitable driver".
I tried to debug my codes, it appears the following codes are OK
try
{
driver = Class.forName("oracle.jdbc.driver.OracleDriver");
}
catch (java.lang.ClassNotFoundException e)
{
return "Driver not found";
}
Seems soemthing wrong with DriverManager.getConnection.
In addition, I got so frustrated that I wrote a server in the the same host and let the servlet in the same directory to open a socket to contact the server. Something make me mad is that I got message of Connection Refused in servlet though I have no problem in the stand alone program again.
I do not understand why driver cannot be found in servlet while it is working well in my application.
Do I need to ask the admin to modify some settings except for put the driver in my own servlet directory?
Or whatever else can I do?
Thanks for your help.
Chris

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: FOR HELP, can not connect to Oracle using JDBC in servlet.