有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java JavaFX setText不工作

Iam正在创建一个可以更改其密码的管理员页面。到目前为止,我的代码是:

@FXML
public void changePasswordButton(ActionEvent e) throws IOException, SQLException {
    try {
        connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/mycredentials?autoReconnect=true&useSSL=false", username, password);
        ps = connection.prepareStatement("SELECT pass FROM managerinfo WHERE pass = '"+oldpasswordBox.getText()+"'");

        ps.setString(1, String.valueOf(oldpasswordBox.getText()));
        ResultSet result = ps.executeQuery();
        if(oldpasswordBox.getText().equals("")) {
            oldpasswordLabel.setText("Please enter your old password.");
        }
        else {
            if(result.next()) {
                if (newPasswordBox.getText().equals("")) {
                    enterNewPassword.setText("Please enter your new password.");
                }
                else {
                    if(newPasswordBox.getText().equals(verifyNewPasswordBox.getText())) {
                        Statement s = (Statement) connection.createStatement();

                        String sql = "UPDATE managerinfo SET pass = '"+ newPasswordBox.getText()+"' WHERE user = 'admin'";
                        s.executeUpdate(sql);
                        passwordChanged.setText("Password Changed.");
                    } 
                    else {
                        didNotMatched.setText("New password did not matched.");
                    }
                }

            }
            else {
                oldPasswordNotMached.setText("Old password did not matched.");
            }

        }
    } catch (SQLException ex) {
        ex.printStackTrace();
    }

}

当我运行代码时,我的setText标签不起作用。我该怎么办?这是错误的逻辑吗


共 (0) 个答案