views:

68

answers:

4

Hi, I'm unable to connect Oracle 10g database.I am getting exception java.lang.ClassNotFoundException:oracle.jdbc.driver.OracleDriver

The code is:

try {
    Class.forName("oracle.jdbc.driver.OracleDriver");
}
catch(ClassNotFoundException e) {
    e.printStackTrace();
}

try {
    con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:system","user" ,"pass");
    stmt=con.createStatement();
}

.......

How can i proceed?

A: 

Remove the space between the 'e' and the 'r'?

Dallas
A: 

You have the Oracle driver in your classpath?

Thorbjørn Ravn Andersen
How to set class classpath? E:\Oracle\oraclexe\app\oracle\product\10.2.0\server\jdbc\lib\ojdbc14.jar is this jar file I have to put in project library?
Depends on your IDE. Do you have a more experienced coworker to ask?
Thorbjørn Ravn Andersen
+1  A: 

First, you have a space " " in your driver class name

Change,

Class.forName("oracle.jdbc.driver.OracleDrive r");

to,

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

Also, fix this error from:

DriverManager.getConnection("jdbc:oracle: thin:@localhost:1521:system","user" ,"pass");

to

DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:system","user" ,"pass");
The Elite Gentleman
still i am getting same exception
You will have to put your oracle driver jar in your classpath.
The Elite Gentleman
+1  A: 

You will probably need to replace system with XE in "jdbc:oracle: thin:@localhost:1521:system"

Gary