user393043
user393043

Reputation: 807

problem in connecting to oracle 10g express edition through java

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?

Upvotes: 0

Views: 5054

Answers (5)

JDGuide
JDGuide

Reputation: 6525

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

Upvotes: 0

Gary Myers
Gary Myers

Reputation: 35401

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

Upvotes: 1

Buhake Sindi
Buhake Sindi

Reputation: 89169

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

Upvotes: 1

You have the Oracle driver in your classpath?

Upvotes: 0

Dallas
Dallas

Reputation: 103

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

Upvotes: 0

Related Questions