Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Chet Arora
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • 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
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic