我想检查用户个人资料表中的员工类型,并选择何时完成用户验证将为该用户加载的内容。
private void jButtonActionPerformed(java.awt.event.ActionEvent evt){
Connection conn = null;
PreparedStatement ps,ps2;
try {
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/hotelmgt","root","");
ps = conn.prepareStatement("SELECT * FROM userprofile WHERE userName = ? AND passWord = ?");
ps2 = conn.prepareStatement("SELECT* FROM userprofile");
ps.setString(1, jTextField_userName.getText());
ps.setString(2, String.valueOf(jPasswordField_login.getPassword()));
ResultSet rs = ps.executeQuery();
ResultSet rs2 = ps2.executeQuery();
if(rs.next()){
while(rs2.next()){
String userType = rs2.getString("emp_Type");
if(userType.equals("ADMIN")){
this.setVisible(false);
Admin_Panel ap = new Admin_Panel();
ap.setVisible(true);
break;
}else if(userType.equals("RCEP")){
this.setVisible(false);
Admin_Panel ap = new Admin_Panel();
ap.setVisible(false);
Reception rcep = new Reception();
rcep.setVisible(true);
break;
}
}
}else{
conn.close();
JOptionPane.showMessageDialog(this,"UserName Or Password Invalid");
}
} catch (SQLException ex) {
Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex);
}
}
答案 0 :(得分:0)
为什么要用于查询此任务?我想你可能想要这样的东西。
@InitBinder("findDocByName")
public void initBinderByName(WebDataBinder binder) {
binder.setDisallowedFields(new String[]{"distance","zipcode"});
}
@InitBinder("findDocByLocation")
public void initBinderByZipCode(WebDataBinder binder) {
binder.setDisallowedFields(new String[]{"distance","name"});
}