• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Database Connection Error

 
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....
 
Ranch Hand
Posts: 2908
1
Spring Java 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!