Home » Developer & Programmer » JDeveloper, Java & XML » ClassNotFoundException: oracle.jdbc.driver.OracleDriver
ClassNotFoundException: oracle.jdbc.driver.OracleDriver [message #92061] Mon, 23 February 2004 10:13 Go to next message
JavaNewBee
Messages: 1
Registered: February 2004
Junior Member
 

Hi All, I was wondering if you could possibly help me out with my dilemma.  I have been trying to connect to an Oracle database using java code, but am having problems, I have searched the Internet high and low for a remedy, but cannot seem to get my connection working. 

Also all the literature regarding my problem as stated below, seems to mention JDK and not SDK, is this maybe a problem that I have overlooked?  Do I need JDK and not SDK?

Problem:  The problem seems to be that for some reason the Java compiler cannot find my Oracle driver.  The error code I am getting is the following:

 

ClassNotFoundException: oracle.jdbc.driver.OracleDriver

 

I have tried many options to rectify this error.  I have downloaded the classes12.zip from the Oracle website and set the classpath to lead to the classes12.zip files.  I have renamed the classes12.zip files to classes12.jar as suggested on the web.  I have put the classes12.jar files into jrelibext subdirectories as also suggested on the web.  I have unzipped the classes12.jar files.

 

I have downloaded the ojdbc14_g.jar files and set the classpath to lead to these files.

 

The version of Java I am using is sdk1.4.2_03

The OS I am using is Windows XP Professional

The Oralce DB is 9.2.0.1 

 

I am compiling the Java code using command prompt.

javac JDBCTest.java (This compiles without generating message)

java JDBCTest (This generates the error as stated above)

 

My most recent attempt of setting the classpath to find the Oracle driver is displayed below.  The C:j2sdk1.4.2_03bin;C:j2sdk1.4.2_03jrelibextclasses12.jaroraclejdbcOracleDriver.class; is the path I set to try and access the OracleDriver.class

 

This is the code I using to connect to the database.

import java.sql.*;

import java.io.*;

//import oracle.jdbc.driver.*;

public class JDBCTest

{

            public static void main(String args[[]]) throws SQLException, IOException

            {

 

 

   Connection conn = null;

   try

   {

           

      Class.forName("oracle.jdbc.driver.OracleDriver");

            //DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

      

 

      conn = DriverManager.getConnection(

                "jdbc:oracle:thin:@localhost:1521:orcl",

                "scott",

                "tiger");

 

      Statement stmt = conn.createStatement();

      ResultSet rs = stmt.executeQuery("SELECT * FROM TestStaff");

 

      //Print start of table and column headers

      System.out.println("
");

       System.out.println("
- ID - - NAME -
");

 

      //Loop through results of query.

      while(rs.next())

      {

          System.out.println("
");

         //out.println(" - " + rs.getString("EmpID") + " - ");

          System.out.println(" - " + rs.getString("Name") + " - ");

          System.out.println("
");

      }

 

       System.out.println("
");

   }

   catch(SQLException e)

   {

       System.out.println("SQLException: " + e.getMessage() + "
");

      while((e = e.getNextException()) != null)

          System.out.println(e.getMessage() + "
");

   }

   catch(ClassNotFoundException e)

   {

       System.out.println("ClassNotFoundException: " + e.getMessage() + "
");

   }

   finally

   {

      //Clean up resources, close the connection.

      if(conn != null)

      {

         try

         {

            conn.close();

         }

         catch (Exception ignored) {}

      }

   }

  }

}

 

 

 

JavaNewbee

 

 

 

 

 

 
Re: ClassNotFoundException: oracle.jdbc.driver.OracleDriver [message #92110 is a reply to message #92061] Thu, 11 March 2004 18:56 Go to previous messageGo to next message
ajay gupta
Messages: 13
Registered: July 2003
Junior Member
Please unzip the classes12.zip file in the c:j2sdk1.4.2_03jrelib directory.

Then set the classpath variable = c:j2sdk1.4.2_03jrelib

Restart your PC for changes of Classpath to take affect and then execute.

Hope this works. This worked for me.
Re: ClassNotFoundException: oracle.jdbc.driver.OracleDriver [message #92263 is a reply to message #92061] Tue, 11 May 2004 03:19 Go to previous messageGo to next message
PRASHANT UPPAL
Messages: 1
Registered: May 2004
Junior Member
HI
JUST SOME MOMENTS AGO I WAS ALSO FACING THE SAME PROBLEM .. THE SOLUTION IS TO CHANGE THE "TNSNAME.ORA" FILE IN THE "C:OraclenetworkADMIN "DIRECTORY. YOU HAVE TO CONFIGURE THE THIS FILE ALONG WITH "SQLNET.ORA " FILE AS PER YOUR DATABASE SPECS..
REGARDS
PRASHANT
Re: ClassNotFoundException: oracle.jdbc.driver.OracleDriver [message #92394 is a reply to message #92061] Mon, 28 June 2004 09:07 Go to previous messageGo to next message
maddeh
Messages: 1
Registered: June 2004
Junior Member
i have the same probleme have you find a solution please help me.
Re: ClassNotFoundException: oracle.jdbc.driver.OracleDriver [message #92402 is a reply to message #92061] Thu, 01 July 2004 23:25 Go to previous messageGo to next message
mustafa calisir
Messages: 1
Registered: July 2004
Junior Member
Hi,

I faced with same problem on a j2ee project while deploying my project on Resin App.Server with connection to oracle 9.2.0.1 database and i used jdk1.4.1. and OS : WinXp professional.

I just changed the classes12.zip as classes12.jar and replaced to the lib directory of my j2ee container( Jboss,Tomcat whatever is it!) and then everything was perfect.

Fisrt there is no need to strut with tnsnames.ora and like other files.You should just add classes12.jar file to your jdk's lib directory where you can see other files too.

Hope this helps.
Re: ClassNotFoundException: oracle.jdbc.driver.OracleDriver [message #92468 is a reply to message #92061] Sun, 01 August 2004 22:39 Go to previous messageGo to next message
Alaa
Messages: 2
Registered: July 2002
Junior Member
put your for oracle driver path in CLASSPATH system variable
Re: ClassNotFoundException: oracle.jdbc.driver.OracleDriver [message #92488 is a reply to message #92061] Wed, 11 August 2004 23:32 Go to previous messageGo to next message
ritesh garg
Messages: 2
Registered: August 2004
Junior Member
Dear

You are using oracle 9i
classes12.zip should copied to
c:oracleora92jdklib
copy this and don't unzip the file
set ClassPath = .;c:oarcleora92jdklib
and try to run
Re: ClassNotFoundException: oracle.jdbc.driver.OracleDriver [message #92491 is a reply to message #92110] Fri, 13 August 2004 02:21 Go to previous messageGo to next message
BRAJESH SINGH DAMAN
Messages: 2
Registered: August 2004
Junior Member
IF U ARE FACING PROBLEM IN TOMCAT 4.0
classes not found:oraclejdbc-----

then

copy the classes12.zip into commonlib folder
and rename it as classes12.jar
set the classpath in environment variable as well
regards
it is working smoothly after that.

Brajesh singh
UTIISL
Re: ClassNotFoundException: oracle.jdbc.driver.OracleDriver [message #92492 is a reply to message #92110] Fri, 13 August 2004 02:39 Go to previous messageGo to next message
BRAJESH SINGH DAMAN
Messages: 2
Registered: August 2004
Junior Member
yeah, I was facing the same problem.

in apache-tomcat4.0
Now don't worry
please copy the classes12.zip into commonlib directory.
wait
and rename it as classes12.jar.
set the environment variable classpath=as ur path

and it will run smoothly.
Better restart ur sustem.
all the best,
Brajesh singh.
Re: ClassNotFoundException: oracle.jdbc.driver.OracleDriver [message #92545 is a reply to message #92061] Fri, 10 September 2004 02:42 Go to previous messageGo to next message
Bharati
Messages: 4
Registered: August 2002
Junior Member
hello
i tried almost all the sugestions given by the experts but the problem is not solved.. Exception listed above still exist...
solution to the above problem is awaited...
regards
bharati
Re: ClassNotFoundException: oracle.jdbc.driver.OracleDriver [message #92621 is a reply to message #92545] Fri, 22 October 2004 00:21 Go to previous messageGo to next message
Ankit Gupta
Messages: 1
Registered: October 2004
Junior Member
Hi ppl,

try this , it will work...

javac YourProgram.java -classpath = oracle.jdbc.driver.Oracle

one more thing check out..
javap oracle.jdbc.driver.Oracle ,,it will give information regarding that class ...

you can contact me .......
java.sql.SQLException:(pls very urgent) [message #92771 is a reply to message #92061] Wed, 12 January 2005 20:12 Go to previous messageGo to next message
mahendar
Messages: 1
Registered: January 2005
Junior Member
i installed j2sdk1.4.2_03 and oracle i set path C:j2sdk1.4.2_03bin;and classpath C:j2sdk1.4.2_03jrelibrt.jar;
i am not getting any expecte results
my program is:
is there any eror in my program
..........................
FirstApp.java
import java.sql.*;
public class Jdbcapp
{
public static void main(String[[]] args) throws Exception
{

// Load JDBC driver class into JVM
// Type I
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection con=DriverManager.getConnection("jdbc:odbc:yourdsn","scott","tiger");

Statement stmt=con.createStatement();

ResultSet rs=stmt.executeQuery("select * from emp");

while(rs.next())
{
System.out.println(rs.getInt(1));
System.out.println(rs.getString(2));
System.out.println(rs.getDouble(3));
}// while()
rs.close();
stmt.close();
con.close();
}// main()
}// class

..................

Exception in thread "main" java.sql.SQLException: Specified driver could not be loaded due to system error 1114 (Oracle ODBC Driver).
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:3074)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:323)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:174)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at Jdbcapp.main(Jdbcapp.java:12)
Re: ClassNotFoundException: oracle.jdbc.driver.OracleDriver [message #92791 is a reply to message #92061] Mon, 24 January 2005 04:08 Go to previous messageGo to next message
farooq
Messages: 12
Registered: July 2001
Junior Member
How you are renaming classes12.zip to classes12.jar?
Long before i faced the same problem, but when i rename classes12.zip through DOS prompt, my problem get solved. It is not the hard and fast solution of your problem, but it could be one reason.......

just use the follwing command on DOS prompt to rename classes12.zip

rename calsses12.zip classes12.jar
Re: ClassNotFoundException: oracle.jdbc.driver.OracleDriver [message #265667 is a reply to message #92791] Thu, 06 September 2007 21:33 Go to previous messageGo to next message
vfar2011
Messages: 1
Registered: September 2007
Junior Member
Hi,

I'm trying to get a data connection from iReport to Oracle XE set on an WIN XP system.

I downloaded CLASSES12.ZIP and RENAMEed it in DOS to CLASSES12.JAR as as previous post suggested.

I copied that file to C:\Program Files\Java\jdk1.6.0_02\jre\lib directory where I had it in the CLASSPATH.

That fixed the ClassNotFoundException problem.

However now it cannot log on to a user DB in Oracle.

The userid/password is valid as I can use SQL Developer with it.

Can anyone please help ?

Thanks in advance, Vern

Here is the error:



Exception


Message:
java.lang.ArrayIndexOutOfBoundsException: 7
Level:
SEVERE
Stack Trace:
oracle.security.o3logon.C1.r(C1)
oracle.security.o3logon.C1.l(C1)
oracle.security.o3logon.C0.c(C0)
oracle.security.o3logon.O3LoginClientHelper.getEPasswd(O3LoginClientHelper)
oracle.jdbc.ttc7.O3log.<init>(O3log.java:290)
oracle.jdbc.ttc7.TTC7Protocol.logon(TTC7Protocol.java:251)
oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:252)
oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:365)
oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:260)
it.businesslogic.ireport.connection.JDBCConnection.getConnection(JDBCConnection.java:105)
it.businesslogic.ireport.connection.JDBCConnection.test(JDBCConnection.java:404)
it.businesslogic.ireport.connection.gui.ConnectionDialog.jButtonTestActionPerformed(ConnectionDialog.java:322)
it.businesslogic.ireport.connection.gui.ConnectionDialog.access$300(ConnectionDialog.java:24)
it.businesslogic.ireport.connection.gui.ConnectionDialog$4.actionPerformed(ConnectionDialog.java:274)
javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
javax.swing.DefaultButtonModel.setPressed(Unknown Source)
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
java.awt.Component.processMouseEvent(Unknown Source)
javax.swing.JComponent.processMouseEvent(Unknown Source)
java.awt.Component.processEvent(Unknown Source)
java.awt.Container.processEvent(Unknown Source)
java.awt.Component.dispatchEventImpl(Unknown Source)
java.awt.Container.dispatchEventImpl(Unknown Source)
java.awt.Component.dispatchEvent(Unknown Source)
java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
java.awt.Container.dispatchEventImpl(Unknown Source)
java.awt.Window.dispatchEventImpl(Unknown Source)
java.awt.Component.dispatchEvent(Unknown Source)
java.awt.EventQueue.dispatchEvent(Unknown Source)
java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
java.awt.Dialog$1.run(Unknown Source)
java.awt.Dialog$3.run(Unknown Source)
java.security.AccessController.doPrivileged(Native Method)
java.awt.Dialog.show(Unknown Source)
java.awt.Component.show(Unknown Source)
java.awt.Component.setVisible(Unknown Source)
java.awt.Window.setVisible(Unknown Source)
java.awt.Dialog.setVisible(Unknown Source)
it.businesslogic.ireport.gui.ConnectionsDialog.jButtonModifyParameterActionPerformed(ConnectionsDialog.java:514)
it.businesslogic.ireport.gui.ConnectionsDialog.jTableParametersMouseClicked(ConnectionsDialog.java:447)
it.businesslogic.ireport.gui.ConnectionsDialog.access$100(ConnectionsDialog.java:53)
it.businesslogic.ireport.gui.ConnectionsDialog$5.mouseClicked(ConnectionsDialog.java:196)
java.awt.AWTEventMulticaster.mouseClicked(Unknown Source)
java.awt.Component.processMouseEvent(Unknown Source)
javax.swing.JComponent.processMouseEvent(Unknown Source)
java.awt.Component.processEvent(Unknown Source)
java.awt.Container.processEvent(Unknown Source)
java.awt.Component.dispatchEventImpl(Unknown Source)
java.awt.Container.dispatchEventImpl(Unknown Source)
java.awt.Component.dispatchEvent(Unknown Source)
java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
java.awt.Container.dispatchEventImpl(Unknown Source)
java.awt.Window.dispatchEventImpl(Unknown Source)
java.awt.Component.dispatchEvent(Unknown Source)
java.awt.EventQueue.dispatchEvent(Unknown Source)
java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
java.awt.Dialog$1.run(Unknown Source)
java.awt.Dialog$3.run(Unknown Source)
java.security.AccessController.doPrivileged(Native Method)
java.awt.Dialog.show(Unknown Source)
java.awt.Component.show(Unknown Source)
java.awt.Component.setVisible(Unknown Source)
java.awt.Window.setVisible(Unknown Source)
java.awt.Dialog.setVisible(Unknown Source)
it.businesslogic.ireport.gui.ConnectionsDialog.setVisible(ConnectionsDialog.java:623)
it.businesslogic.ireport.gui.MainFrame.jMenuItemConnectionsActionPerformed(MainFrame.java:6466)
it.businesslogic.ireport.gui.MainFrame.access$13800(MainFrame.java:101)
it.businesslogic.ireport.gui.MainFrame$175.actionPerformed(MainFrame.java:3757)
javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
javax.swing.DefaultButtonModel.setPressed(Unknown Source)
javax.swing.AbstractButton.doClick(Unknown Source)
javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
java.awt.Component.processMouseEvent(Unknown Source)
javax.swing.JComponent.processMouseEvent(Unknown Source)
java.awt.Component.processEvent(Unknown Source)
java.awt.Container.processEvent(Unknown Source)
java.awt.Component.dispatchEventImpl(Unknown Source)
java.awt.Container.dispatchEventImpl(Unknown Source)
java.awt.Component.dispatchEvent(Unknown Source)
java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
java.awt.Container.dispatchEventImpl(Unknown Source)
java.awt.Window.dispatchEventImpl(Unknown Source)
java.awt.Component.dispatchEvent(Unknown Source)
java.awt.EventQueue.dispatchEvent(Unknown Source)
java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
java.awt.EventDispatchThread.pumpEvents(Unknown Source)
java.awt.EventDispatchThread.pumpEvents(Unknown Source)
java.awt.EventDispatchThread.run(Unknown Source)
Re: ClassNotFoundException: oracle.jdbc.driver.OracleDriver [message #286174 is a reply to message #265667] Thu, 06 December 2007 12:38 Go to previous message
kschai
Messages: 1
Registered: December 2007
Junior Member
Just go to Options...Classpath in Ireport, and add the oracle jdbc jar. Mine in C:\oraclexe\app\oracle\product\10.2.0\server\jdbc\lib.

That should work! Good Luck.
Previous Topic: copy files
Next Topic: insertXML and special char like ampersand &amp
Goto Forum:
  


Current Time: Sat Dec 03 04:09:16 CST 2016

Total time taken to generate the page: 0.05307 seconds