JDBC while(!rs.next()) is stuck in a loop

Trying to make a login with sql that lets the user re-enter the username and password if one of them doesnt match what is in the database. The problem is that when the username and password does match, it keeps asking the user for the information again instead of stopping the loop. I am not sure, but I think the culprit might be the while(!rs.next());

public void loginAccount(Connection conn) throws SQLException {
        String login;
        ResultSet rs;

        do {
            System.out.print("Enter Username: ");
            Username = in.nextLine();
            System.out.print("Enter Password: ");
            Password = in.nextLine();

            login = "SELECT * FROM Person WHERE Username = ? AND AccPassword = ?";
            PreparedStatement ps = conn.prepareStatement(login);

            ps.setString(1, Username);
            ps.setString(2, Password);

            rs = ps.executeQuery();

            if (!rs.next()) {
                System.out.println("Incorrect Username or Password");
            }
        }   while (!rs.next());

    }

Solution 1:

As commented, your second call is returning false.

Be aware that this behavior is up to the implementation of the JDBC driver. A second call to next (after the first returned false) might return false or might throw an exception.

To quote the Javadoc:

If the result set type is TYPE_FORWARD_ONLY, it is vendor specified whether their JDBC driver implementation will return false or throw an SQLException on a subsequent call to next.

You need to change your code to call rs.next() only once per intended row access.