mardi 21 novembre 2017

Java if control error [duplicate]

This question already has an answer here:

I have a database system and program that connected this databases . I want to control password(Users enter 2 password. If passwords are the same, program continue.

try {
    //Register
    dbconnection register = new dbconnection();
    Connection connection = register.getConnection();
    String query ="insert into users values(?,?,?,?,?)";
    PreparedStatement statement = connection.prepareStatement(query);
    statement.setString(1,TexFieldUserNameReg.getText());
    statement.setString(2,TexFieldUserPass1Reg.getText());
    statement.setString(3, TexFieldUseraMailReg.getText());
    statement.setString(4, TexFieldNameReg.getText());
    statement.setString(5,TexFieldSurnameReg.getText());

    String password1 = TexFieldUserPass1Reg.getText();
    String password2 = TexFieldUserPass2Reg.getText();
    JOptionPane.showMessageDialog(null,password1);
    JOptionPane.showMessageDialog(null,password2);
    if(password1 == password2)
    {
        statement.execute();
        JOptionPane.showMessageDialog(null,"Registration succeed");
    }
    else
    {
        JOptionPane.showMessageDialog(null,"passwords incompatible");
    }
} catch (SQLException ex) {
    Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex);
}

Aucun commentaire:

Enregistrer un commentaire