try {
Connection conn = DBConnection.connect();
PreparedStatement pst = null;
ResultSet rs = null;
boolean error = false;
String uname = username.getText().trim();
String pword = password.getText().trim();
if(uname.isEmpty()){
error = true;
//JOptionPane.showMessageDialog(null,"UserName Cannot be empty.");
//errorla.setText("UserName Cannot be empty !.");
}
if(pword.isEmpty()){
error = true;
//JOptionPane.showMessageDialog(null,"Password Cannot be empty.");
//errorla.setText("Password Cannot be empty !.");
}
if(error){
errorla.setText("UserName & Password Cannot be empty !.");
}
String loginsql = "SELECT ID,First_Name,Last_Name FROM WHERE
User_Name=? AND Password=?";
pst = (PreparedStatement)conn.prepareStatement(loginsql);
pst.setString(1,uname);
pst.setString(2, pword);
rs = pst.executeQuery();
if(rs.next()){
SystemDashbord obj = new SystemDashbord();
obj.setVisible(true);
this.dispose();
JLabel Session = new JLabel(uname);
obj.add(Session);
obj.setLayout(null);
obj.setVisible(true);
}else{
errorla.setText("UserName or Password Invalid !.");
}
//SystemDashbord mydb = new SystemDashbord();
// mydb.setVisible(true);
//this.dispose();
} catch (SQLException ex) {
Logger.getLogger(SystemLogin.class.getName()).log(Level.SEVERE, null,
ex);
}