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

Does JDBC support stored procedures?

0 Answers  


What is difference between java.util.Date and java.sql.Date?

0 Answers  


What packages are used by jdbc?

0 Answers  


What is difference between statement and preparedstatement in jdbc?

0 Answers  


How to execute bulk number of queries at once?

3 Answers   Wipro,






Is possible to open a connection to a database with exclusive mode with JDBC?

0 Answers  


Why is jdbc needed?

0 Answers  


What is new in JDBC 2.0?

0 Answers  


Does the JDBC-ODBC Bridge support multiple concurrent open statements per connection?

0 Answers  


What are the different types of 2 tier and 3 tier architecture ?

2 Answers   Honeywell,


Does jdbctemplate close connection?

0 Answers  


What is two-phase commit in the database?

0 Answers  


Categories