connection = Sqliteconnection.dbConnector();
try { String query ="select * from hms1 where DEPARTMENT = ? and USERNAME = ? and PASSWORD = ? "; PreparedStatement pst = connection.prepareStatement(query); pst.setString(1,JFIELD1.getText()); pst.setString(2,jTextField1.getText()); pst.setString(3,jPasswordField1.getText()); ResultSet rs = pst.executeQuery(); int count=0; while(rs.next())
{
count = count+1;
}
if (count == 1)
{
JOptionPane.showMessageDialog(null,"YOU ARE SUCCESSFULLY LOGGED IN !!!");
Panel3.setVisible(true);
jPanel1.setVisible(false);
panel.setVisible(false);
jPanel2.setVisible(false);
}
else if (count >1)
{
JOptionPane.showMessageDialog(null,"INVALID DEPARTMRNT , USERNAME OR PASSWORD ");
}
else {
JOptionPane.showMessageDialog(null,"INVALID USERNAME OR PASSWORD ");
rs.close();
pst.close();
}
}
catch (SQLException ex) {
JOptionPane.showMessageDialog(null,ex);
Logger.getLogger(Gh.class.getName()).log(Level.SEVERE, null, ex);
}
}
Connection connection = null;
Aucun commentaire:
Enregistrer un commentaire