0

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?

5 Answers 5

1

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");
Sign up to request clarification or add additional context in comments.

2 Comments

still i am getting same exception
You will have to put your oracle driver jar in your classpath.
1

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

Comments

0

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

Comments

0

You have the Oracle driver in your classpath?

2 Comments

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?
0

Its a problem with the given url. Please correct the url with accurate host name,port no,user name & password.Do not use the port number(8080) that you are using with browser when you are running you application oracle 10g express edition.Simply user the default port number 1521.

Please find the example below:-

String driver="oracle.jdbc.driver.OracleDriver";            

Class.forName(driver);
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","manoj","manoj");
  • user name=manoj
  • password=manoj
  • port no=1521
  • service name=XE
  • Host=Localhost

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.