Reputation: 807
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
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");
Upvotes: 0
Reputation: 35401
You will probably need to replace system with XE in "jdbc:oracle: thin:@localhost:1521:system"
Upvotes: 1
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
Reputation: 75376
You have the Oracle driver in your classpath?
Upvotes: 0