Have u checked what u r getting in string u1 and p1
and the second thing is that why u r using rs.next()
two times???
rs.next();
>
> while(rs.next())
>
> {
...
..
}
Don't fetch all records for authentication you can
modiff your query like this one
String query="select count(*) from Registration where
user=u1 and password=p1;";
if(rs.next())
{
// if found 1 than user exists //rs.getInt..(1);
}
For better performance u can also go for
preparedstatement instead of statement.
if your code is for learning purpose than it is
OK......