0% found this document useful (0 votes)
9 views2 pages

2

Uploaded by

dilankasilva86
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

2

Uploaded by

dilankasilva86
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

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);
}

You might also like