Action Performed :
try
{
Connection connect = Connect.getConnect(); //Your Source Database
Statement stat = (Statement) connect.createStatement();
String sql="Select * from login where username=? and password=?";
PreparedStatement prt = connect.prepareStatement(
String nama,pass;
name = txname.getText();
pass = txpw.getText();
prt.setString(1, name);
prt.setString(2, pass);
ResultSet rs = prt.executeQuery();
if(name.equals("admin") && pass.equals("admin")) // Not Using Database
{
JOptionPane.showMessageDialog(null,"Congratulation success login",
"Success", JOptionPane.INFORMATION_MESSAGE);
new menu().setVisible(true);
setVisible(false);
}
else if (rs.next()) { //Using Database
JOptionPane.showMessageDialog(null,"Congratulation success login",
"Success", JOptionPane.INFORMATION_MESSAGE);
new menu().setVisible(true);
setVisible(false);
}
else {
JOptionPane.showMessageDialog(null, "Sorry, Failed","Data Error", JOptionPane.ERROR_MESSAGE);
}
}
catch (Exception ex)
{
JOptionPane.showMessageDialog(null,"Error :"+ex);
}
try
{
Connection connect = Connect.getConnect(); //Your Source Database
Statement stat = (Statement) connect.createStatement();
String sql="Select * from login where username=? and password=?";
PreparedStatement prt = connect.prepareStatement(
String nama,pass;
name = txname.getText();
pass = txpw.getText();
prt.setString(1, name);
prt.setString(2, pass);
ResultSet rs = prt.executeQuery();
if(name.equals("admin") && pass.equals("admin")) // Not Using Database
{
JOptionPane.showMessageDialog(null,"Congratulation success login",
"Success", JOptionPane.INFORMATION_MESSAGE);
new menu().setVisible(true);
setVisible(false);
}
else if (rs.next()) { //Using Database
JOptionPane.showMessageDialog(null,"Congratulation success login",
"Success", JOptionPane.INFORMATION_MESSAGE);
new menu().setVisible(true);
setVisible(false);
}
else {
JOptionPane.showMessageDialog(null, "Sorry, Failed","Data Error", JOptionPane.ERROR_MESSAGE);
}
}
catch (Exception ex)
{
JOptionPane.showMessageDialog(null,"Error :"+ex);
}
No comments:
Post a Comment