Remove rs.next() before the while loop. Anyway rs.next() is there in while loop
condition, it will work.
Instead of checking with while loop you can do the following
Sql = query="select * from Registration where username=<username> and password =
<password>";
If (rs.next()) return true;
else return false;