-
jdbc connectivity error
What driver can I use for database connectivity with Oracle 9i? I created a new driver using administrative tools --> Data sources(ODBC).
I'm having trouble establishing database connectivity.
Code:
private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {
String user= new String(jTextField1.getText());
String pass= new String(jPasswordField1.getPassword());
if(a<4)
{
Connection con = null;
String driver = "oracle.jdbc.driver.OracleDriver";
String user1 = "system";
String pass1 = "manager";
try{
Class.forName(driver);
con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521/test",user1,pass1);
Statement s=con.createStatement();
ResultSet password=s.executeQuery("Select pass from login where username="+user);
s.close();
con.close();
if(pass.contentEquals(password.getString(1)))
{
a=0;
JOptionPane.showMessageDialog(rootPane, "Access Granted");
ResultSet access=s.executeQuery("Select access_power from login where username="+user);
access_power=access.getString(1);
new Exam_Season().setVisible(true);
this.setVisible(false);
}
else
{
JOptionPane.showMessageDialog(rootPane, "Access Denied.");
a++;
}
}
catch(Exception e)
{
e.printStackTrace();
JOptionPane.showMessageDialog(rootPane, "Connection not successful.");
}
}
else
{
JOptionPane.showMessageDialog(rootPane, "Too many attempts.");
System.exit(0);
}
}
-
What error do you get?
You can always download JDBC driver,
like "ojdbc14.jar" place it in classpath and try.
regards
-
Class not found is the error I get.