Hello Daniwebers,
I have my login form inwhich I read the value in mysql table to identify whether the password match with the role. I have on combobox with different roles(director, assistant...) which I have filled in manually. It does the work but I would like to do something else when the user login as the Director(display a different form). I know that I will have to check if cb1 = "director" but have no idea how to do that. Any help will be appreciated.
public void loginACCT(String pass, String role) {
ResultSet rs = null;
Properties conProps = new Properties();
conProps.setProperty("user", "root");
conProps.setProperty("password", "root");
try {
con = DriverManager.getConnection ("jdbc:mysql://localhost:3306/stock", conProps);
con.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE );
} catch (SQLException ex) {
}
String sql = ("select * from users where Password = ? and Role = ? ");
try {
con.setAutoCommit(false);
st = con.prepareStatement(sql);
st.setString(1,pass );
st.setString(2,role );
st.executeQuery();
rs = st.getResultSet();
if(rs.next()){
JOptionPane.showMessageDialog(null, "Welcome, You are now logged in the System!");
Main ob = new Main(); // display main form
ob.setVisible(true);
this.dispose();
} else {
JOptionPane.showMessageDialog(null, "You have entered an incorrect password!");
p1.setText("");
}
st.close();
con.commit();
}
catch (Exception e) {
System.out.println(e);
}
//notifyListener();
}