java.lang.ClassNotFoundException:oracle.jdbc.driver.OracleDr
iver? I get this error at run time.I used oracle10G. I set
CLASS PATH:C:\oraclexe\app\oracle\product\10.2.0
\server\jdbc\lib\ojdbc14.jar;
I write JDBC PROGRAM like
import java.sql.*;

class Example
{
public static void main(String args[])
{
try
{
Class.forName
("oracle.jdbc.driver.OracleDriver");
System.out.println("Driver Loaded");
Connection con=DriverManager.getConnection
("jdbc:oracle:thin:@localhost:1521:xe","system","salmas");
System.out.println("Driver Connected");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from
emp");
while(rs.next())
{
System.out.println(rs.getInt(1));
System.out.println(rs.getString(2));
System.out.println(rs.getString(3));
}
st.close();
con.close();
}

catch(Exception e)
{
System.out.println(e);
}

finally
{
System.out.println("it's
finally block executed");
}

}
}

Answers were Sorted based on User's Feedback



java.lang.ClassNotFoundException:oracle.jdbc.driver.OracleDr iver? I get this error at run time.I ..

Answer / amit singh

have you set the enoviornment variable if not then beacuse
of this the driver can not be load
because which you path
Class.forName
("oracle.jdbc.driver.OracleDriver");
in Class.forName("String" )
compiler search it out in bin/lib of jre or jre bin/lib/ext
so please check it out because of it this excption commonly
come
because if some one used Mysql and i did in past i got thsi
exception because it didn't set the Classpath for connection.jar
so do it getridof this thing
thanks
amitsing2008@gmail.com
amit09mca

Is This Answer Correct ?    2 Yes 0 No

java.lang.ClassNotFoundException:oracle.jdbc.driver.OracleDr iver? I get this error at run time.I ..

Answer / mohit

i hav faced same problem...
still i didnt get right answere

Is This Answer Correct ?    1 Yes 2 No

java.lang.ClassNotFoundException:oracle.jdbc.driver.OracleDr iver? I get this error at run time.I ..

Answer / deepak

just find the file named classes.jar in the oracle installed
directory.and copy the full address of classes.jar with the
file name and goto command prompt and write the
(this is for oracle 11g)

c:\>set
classpath=D:\app\Deepak\product\11.2.0\dbhome_1\oui\jlib\classes12.jar;.;

this sets ur classpath teprorily for that session
now run the command for checking that the classpath is seted
properly.
c:\>java oracle.jdbc.driver.OracleDriver
Exception in thread "main" java.lang.NoSuchMethodError: main

if this is shown then now u can run ur program.

Is This Answer Correct ?    2 Yes 4 No

java.lang.ClassNotFoundException:oracle.jdbc.driver.OracleDr iver? I get this error at run time.I ..

Answer / renuka

I have tried that I got this

C:\connection>java oracle.jdbc.driver.OracleDriver
Exception in thread "main" java.lang.NoSuchMethodError: main

but still my program is not running. I am getting the
following error

C:\connection>java -classpath . getOracleConnection
Exception in thread "main" java.lang.NoClassDefFoundError:
oracle/jdbc/OracleDri
ver
at DB.dbConnect(getOracleConnection.java:26)
at getOracleConnection.main(getOracleConnection.java:10)
Caused by: java.lang.ClassNotFoundException:
oracle.jdbc.OracleDriver
at java.net.URLClassLoader$1.run(Unknown Source)
at
java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at
sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)

Is This Answer Correct ?    0 Yes 2 No

java.lang.ClassNotFoundException:oracle.jdbc.driver.OracleDr iver? I get this error at run time.I ..

Answer / vishnu

iam usin type 4 driver .using oracle 10g.when i am trying to run the code error came like this Exception in thread "main" java.lang.ClassNotFoundException: oracle.jdbc.
OracleDriver.

Is This Answer Correct ?    0 Yes 2 No

java.lang.ClassNotFoundException:oracle.jdbc.driver.OracleDr iver? I get this error at run time.I ..

Answer / vijay

Hey,
You are written In valid Driver name
use following script
Then you can't get that problam.

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

in Driver "D" should capital

Is This Answer Correct ?    1 Yes 16 No

Post New Answer

More JDBC Interview Questions

How to create Connection interface object because it is Interface , Interface is not instansiated?

9 Answers   Aptech, CTS, HCL,


Can I get a null resultset?

0 Answers  


How to invoke Oracle Stored Procedure with Database Objects as IN/OUT?

0 Answers  


What is a jdbc url?

0 Answers  


What is resultset?

0 Answers  


How to check jdbc driver version in websphere?

0 Answers  


How to get the data from a table into a buffer?

2 Answers  


What are the main steps in java to make JDBC connectivity?

0 Answers   UGC Corporation,


What is the use of statement in jdbc?

0 Answers  


What are different types of transactions?

2 Answers   HCL,


What are the common tasks of JDBC?

0 Answers  


Write a program JDBCcode forfetching student database with SQL.

0 Answers  


Categories