• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Database Connection Error

 
Rashmi Dupati
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I have used type jdbc driver in my application ...but it's not working...
It's showing some exception...java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver

please see the code below.....

boolean login(String userName, String password) {
try {
Class.forName ("oracle.jdbc.driver.OracleDriver");
Connection con =
DriverManager.getConnection("jdbc racle:thin:@127.0.0.1:1521:rashviji","scott","tiger");

System.out.println("got connection");

Statement s = con.createStatement();
String sql = "SELECT UserName FROM Users1" +
" WHERE UserName='" + userName + "'" +
" AND Password='" + password + "'";
ResultSet rs = s.executeQuery(sql);
if (rs.next()) {
rs.close();
s.close();
con.close();
return true;
}
rs.close();
s.close();
con.close();
}
catch (ClassNotFoundException e) {
System.out.println(e.toString());
}
catch (SQLException e) {
System.out.println(e.toString());
}
catch (Exception e) {
System.out.println(e.toString());
}
return false;
}

Please give the solution to this problem...thanks in advance....
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all , put this question in JDBC forum section , where many people can answer it .

and for the error, it seems that program is not able to find the specified Oracle driver , so put that jar file which contain Driver code in CLASSPATH.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic