Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

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 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

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!