方法检查登录名和密码

| 此方法应将用户提供的登录名/密码与数据库中存储的登录名/密码进行比较,但是此方法始终返回false,指令braek不起作用!
public String loginPasswordCheck() {
    Connectionx cx = new Connectionx();
    Connection con = (Connection) cx.Connxion(\"com.mysql.jdbc.Driver\",\"jdbc:mysql://localhost/kpidb\", \"root\", \"root\");
    String log;
    String pwd;
    String checkaccess = \"success\";
    int profil_user;
    HashMap<String, String> mapLoginPWD = new HashMap<String, String>();
    HashMap<String, HashMap<String, String>> mapID_LoginPWD = new HashMap<String, HashMap<String, String>>();
    HashMap<String, String> temp = new HashMap<String, String>();
    String sqlLogin;
    sqlLogin = \"select PROFIL_USER_ID,login ,password from profil_user;\";

    try {

        st = (PreparedStatement) con.prepareStatement(sqlLogin);
        ResultSet rs1 = st.executeQuery();

        while (rs1.next()) {
            profil_user = rs1.getInt(\"PROFIL_USER_ID\");
            profil_user_id = String.valueOf(profil_user);

            log = rs1.getString(\"login\");
            pwd = rs1.getString(\"password\");
            mapLoginPWD.put(log, pwd);
            mapID_LoginPWD.put(profil_user_id, mapLoginPWD);
            Iterator iteratorkeymaploginPWD = mapID_LoginPWD.keySet().iterator();

            while (iteratorkeymaploginPWD.hasNext()) {

                String myKeylog = (String) iteratorkeymaploginPWD.next();
                temp = mapID_LoginPWD.get(myKeylog);

                Iterator iteratortemp = temp.keySet().iterator();
                while (iteratortemp.hasNext()) {

                    String keyTemplog = (String) iteratortemp.next();
                    String valueTemppwd = temp.get(keyTemplog);
                    temp.clear();
                    mapID_LoginPWD.clear();
                    boolean bool = true;
                    if (!(this.login.equalsIgnoreCase(keyTemplog)) && !(this.password.equalsIgnoreCase(valueTemppwd)) && (bool)) {

                        bool = false;
                        checkaccess = \"fail\";
                    } else {
                        checkaccess = \"success\";
                        break;
                    }
                }
            }
        }
    }
    catch (SQLException e) {
        e.printStackTrace();
    }
    return checkaccess;
}
    
已邀请:
        逻辑很难遵循,但我相信
boolean bool = true;
需要先来
while (iteratortemp.hasNext()) {
    

要回复问题请先登录注册