Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Servlets and the fly likes Having a problem connecting to Oracle using JDBC type 2 OCI driver Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Having a problem connecting to Oracle using JDBC type 2 OCI driver" Watch "Having a problem connecting to Oracle using JDBC type 2 OCI driver" New topic
Author

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

Chet Arora
Greenhorn

Joined: May 20, 2003
Posts: 29
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

Joined: Jan 07, 1999
Posts: 6920
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.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Having a problem connecting to Oracle using JDBC type 2 OCI driver
 
Similar Threads
PSQLException
uploading.....
How to connect to MS ACCESS through our own Driver
oracle database problems
connect oracle database