Answer the question
In order to leave comments, you need to log in
Why do the lines from the database and from the form do not match?
There is this piece of code:
System.out.println("login :" + loginField.getText());
System.out.println("pass from fo:" +passwordField.getText());
DBHandler.openConnection();
ResultSet resultSet = DBHandler.executeUpdate("SELECT * FROM users WHERE login = '"+loginField.getText()+"'");
String passwordFromDB = null;
try {
while (resultSet.next()) {
passwordFromDB = resultSet.getString("password");
}
} catch (SQLException throwables) {
throwables.printStackTrace();
}
System.out.println("pass from DB :" + passwordFromDB);
if (passwordFromDB.toString() == passwordField.getText().toString()) {
System.out.println(1);
}
DBHandler.closeConnection();
Answer the question
In order to leave comments, you need to log in
You are not comparing strings, but references to string objects.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question