In my code, I am trying to get a user with the username = "Jason" and has a password of "1234". However, the query that I am using is not returning any values in Java. On the other hand, when I write the same query on my SQL bench it returns a row.
@FXML
private TextField tf_username;
@FXML
private TextField pf_password;
@FXML
void logIn(MouseEvent event) throws SQLException, IOException {
String username = tf_username.getText();
String password = pf_password.getText();
String checkPassSql = "select * from users where username" + " = '"+username+"'and password = '"+password+"' ";
Connection connection = DbConnect.getInstance().getConnection();
Statement statement = connection.createStatement();
ResultSet rs = statement.executeQuery(checkPassSql);
if(rs.next()){
//change the next line from signUp scene to home scene
Parent root = FXMLLoader.load(getClass().getResource("home.fxml"));
Node node = (Node) event.getSource();
Stage stage = (Stage) node.getScene().getWindow();
stage.setScene(new Scene(root));
}
}