Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver

843838Apr 7 2007 — edited May 14 2009
I've read up on as much as I can and still have an issue connecting to an Oracle 10g Express database from my JVM.
I have the following up and running:
Apache Tomcat 4.1
Java 2 SDK, SE v1.4.1_02
Oracle Database 10g Express Edition

The java install is in: c:\java
The tomcat install is in: c:\tomcat

Environment Variables:
CATALINA_HOME c:\tomcat
CLASSPATH C:\java\lib\tools.jar;c:\tomcat\common\lib\servlet.jar;c:\java\lib\classes12.jar;c:\java\lib\ojdbc14.jar;
J2SE_HOME c:\java
JAVA_HOME c:\java
JAVA14_HOME c:\java
TOMCAT_HOME c:\tomcat

Directory of C:\java\lib

04/07/2007 08:35 AM <DIR> .
04/07/2007 08:35 AM <DIR> ..
04/06/2007 10:14 AM 1,600,090 classes12.jar
...
02/01/2006 09:56 PM 1,536,797 ojdbc14.jar
...
02/20/2003 02:17 PM 4,928,143 tools.jar
9 File(s) 8,637,438 bytes

Directory of C:\tomcat\common\lib

01/12/2007 10:25 PM <DIR> .
01/12/2007 10:25 PM <DIR> ..
...
03/19/2003 05:17 AM 80,054 servlet.jar
...
17 File(s) 6,861,778 bytes

I've tried just the classes12.jar and the ojdbc14.jar files individually and together (as shown above) in the CLASSPATH.
I downloaded both of these files from the Oracle website. They are displayed on the website as .jar files but they show up as .zip files. I've tried them as both .zip and then renaming them .jar.
I downloaded and installed the Oracle 10g Express client and tried its ojdbc14.jar file (which appears to be identical to the website's version).

I can get this to work with the JDBC-ODBC bridge, so I know that the database/user are working.

My test2.jsp file is very basic:
<%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%
Connection con = null;
Statement stmt = null;
String DBDriver = "oracle.jdbc.driver.OracleDriver";
String DBUrl = "jdbc:oracle:thin:@localhost:1521:XE";
String DBUserName = "scott";
String DBUserPass = "tiger";
String username = request.getRemoteUser();

try
{
Class.forName(DBDriver);
con = DriverManager.getConnection (DBUrl,DBUserName,DBUserPass);
stmt = con.createStatement();
ResultSet rsTable = null;
rsTable = stmt.executeQuery("SELECT * FROM T1");
while (rsTable.next())
{
out.println(rsTable.getInt("i"));
}
rsTable.close();
stmt.close();
con.close();
}
catch (Exception e)
{
out.println("Error: "+e+"<br>");
try {out.println("con.close().<br>"); con.close();} catch (Exception e1) {out.println("con.close() Error: "+e1+"<br>");}
}
%>
<html>
<head>
<title>T1 Table</title>
</head>
<body>
Logged In: <%=username%>
</body>
</html>


No matter what I've tried to do, I still get 'java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver'!

The output of test2.jsp is:
Error: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
con.close().
con.close() Error: java.lang.NullPointerException
Logged In: scott

How do I get this to work??!!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 11 2009
Added on Apr 7 2007
4 comments
1,073 views