伙计们,我整天都在尝试让我的 managerCorner GUI 基于此身份验证执行。我使用了正确的值,即我的数据库中的值来检查 managerLogin() 方法是否将授予我访问 managerCorner GUI 界面的权限,但它没有工作。有一个带有处理用户身份验证表单的 LoginInterface 类。我已经尝试使用正确的值登录,但是 if(rset.next())... 中的 managerCorner GUI 类没有被调用,没有异常或错误被标记出来!为什么会这样?
public void managerLogin(int id, String usn, String pwd) {
try {
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
}
catch(Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage());
}
java.sql.Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/ phoneShopSystem","aknessy", dbLogin.db());
String query = "SELECT managerID, managerUsername, managerPwd"
+ "FROM `manager` WHERE managerID = ? AND managerUsername = ? AND managerPwd = ?";
java.sql.PreparedStatement pst= con.prepareStatement(query,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
int i = rset.getInt(1);
String u = rset.getString(2);
String p = rset.getString(3);
rset = pst.executeQuery();
if(rset.next()){
if((i == id) && (u.equals(usn)) && (p.equals(pwd))){
new managerCorner();
managerCorner.setDefaultLookAndFeelDecorated(true);
}else{
JOptionPane.showMessageDialog(null, "The User: "+ usn +" With ID "+ id + " \n"
+ "Does Not Exist!", "\nLogin Failed!", JOptionPane.OK_OPTION);
}
rset.close();
con.close();
}catch(SQLException sql){
JOptionPane.showMessageDialog(null, sql.getMessage(),"SQL ERROR!!!",JOptionPane.OK_OPTION);
}
}}