Win a copy of Create an Uber Clone in 7 Days: Build a real world full stack mobile app in Java this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
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
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.

You have to be odd to be #1 - Seuss. An odd little ad:
Why should you try IntelliJ IDEA ?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!