• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Having a problem connecting to Oracle using JDBC type 2 OCI driver

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Im writing a servlet which should connect to an oracle database
and retrieve some data. When i do this from a java application it
runs fine but it doesnt work when i use the same code in a servlet.
Is it that Type 2 drivers dont work with servlets ? What are my
alternatives ?
Am pasting relavent code:
String sConn = "jdbc racle ci8:admin/admin@FRAME";


PreparedStatement pstmt = null;
ResultSet rs = null;


try {

String str = "oracle.jdbc.driver.OracleDriver";
Class.forName(str);
}
catch(ClassNotFoundException c) {
out.println("Class.forName failed");
}

.........................
.........................
Please advise.
Thanx,
Chetan
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can guess that this is probably a classpath issue. It looks like the container is not providing the Oracle driver classes to your application.
In general, command line applications make use of the CLASSPATH environment variable, or a classpath specified as a command-line parameter when the application is started. Servers, on the other hand, usually ignore the system CLASSPATH and have their own mechanism for providing classes to contained applications.
You probably need to put the Oracle driver classes either in the container "lib" directory (to be shared between all loaded applications), or into WEB-INF/lib (if a jar file) or WEB-INF/classes (if a bunch of regular class files) in your web application.
reply
    Bookmark Topic Watch Topic
  • New Topic