ClassNotFoundException: oracle.jdbc.driver.OracleDriver [message #92061] |
Mon, 23 February 2004 10:13 |
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 #92402 is a reply to message #92061] |
Thu, 01 July 2004 23:25 |
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.
|
|
|
|
|
|
|
|
|
java.sql.SQLException:(pls very urgent) [message #92771 is a reply to message #92061] |
Wed, 12 January 2005 20:12 |
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 |
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 |
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)
|
|
|
|