我正在制作一个系统,用于验证数据库中已经定义的凭据与在 jTextfield 中输入的凭据。当我在 if-else 语句中输入条件时,它说不能字符串不能转换为布尔值。请帮忙。
Connection con = (Connection) DriverManager.getConnection (host, uName, uPass);
Statement stmt = (Statement) con.createStatement ();
//login is a table in my database,password a tuple
String SQL = "SELECT password FROM login;";
ResultSet password = stmt.executeQuery (SQL);
String pass = adminpassword.getText();
String sqlpass = password.getString("password");
//error shows on if else below
if(sqlpass = pass){
JOptionPane.showMessageDialog(null,"You have entered an incorrect password,please try again.","Incorrect Password",JOptionPane.WARNING_MESSAGE);
}
else{
String passconfirm = "SELECT admin_id WHERE password = 77353";
ResultSet confirmpass = stmt.executeQuery(passconfirm);
JOptionPane.showMessageDialog(null,"Welcome","Welcome " + confirmpass,JOptionPane.INFORMATION_MESSAGE);
Countyinfo proceed = new Countyinfo();
proceed.setVisible(true);
}
}
catch(SQLException err){
System.out.println (err.getMessage());
};