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
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 |
Answer / mohit
i hav faced same problem...
still i didnt get right answere
Is This Answer Correct ? | 1 Yes | 2 No |
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 |
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 |
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 |
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 |
How do you create Connection?
Why can't Tomcat find my Oracle JDBC drivers in classes111.zip?
How a database driver can be loaded with jdbc 4.0 / java 6?
Does the JDBC-ODBC Bridge work with Microsoft J++?
What is meant by connection string?
Which jdbc driver type s is are the jdbc odbc bridge?
What is <discriminator > in Hibernate? How exactly inheritance of Object to Tables can be done? What is the benefits of discriminator?
What is the query used to display all tables names in SQL Server (Query analyzer)?
How can I get information about foreign keys used in a table?
Does multiple concurrent open statements per connection are supported by the JDBC-ODBC Bridge?
How do I write Greek ( or other non-ASCII/8859-1 ) characters to a database?
What are the differences between statement and preparedstatement interface?