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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to use JDBC to connect Microsoft Access?

840


What is JDBC Statement?

780


Give a way to check that all result sets have bin accessed and update counts are generated by execute method.

704


What are the different types of drivers under jdbc?

668


What is hbm xml?

685


What is two-phase commit in the database?

750


What are the packages are used in jdbc?

807


What is the purpose of jdbc?

805


How do I insert/update records with some of the columns having NULL value?

724


What is the meaning of batch updates?

824


What is the difference between executing, executequery, executeupdate in jdbc?

785


Why should we close database connections in java?

934


Name different methods for getting streams.

765


Explain about the drive manager class working?

846


How to connect html page to database using jdbc?

694