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");
}

}
}

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Give an example of code used for setting up connection with a driver.

714


Explain about multiple implementations and drive manager?

797


How does jdbc connect to database?

648


Is jdbc faster than odbc?

671


What is a jdbc url?

647


What do you understand by DDL and DML statements?

702


What is jdbc and its advantages?

718


What is the difference between client and server database cursors?

818


What is the limitation of PreparedStatement and how to overcome it?

856


Compare jdbc and odbc and how is jdbc required in this context.

710


Why we use jdbc instead of odbc?

721


How to know howmuch data is truncated?

2106


What do you understand by jdbc datasource?

788


What is the most common example type 1 driver?

788


What is JDBC Batch Processing and what are it’s benefits?

712