Im trying to write a function for authentication using JDBC.My function is
boolean authenticate(String enteredPassword)throws SQLException{
String query="select password from Manager where email=?";
PreparedStatement stmt=con.prepareStatement(query);
stmt.setString(1,"ivedantlodha@gmail.com");
ResultSet rs=stmt.executeQuery();
rs.next();
String password=rs.getString(1);
if(enteredPassword.equals(password))
return true;
return false;
}
The function throws SQLException Exhausted ResultSet. The output of rs.next() is false. On executing the following query on sql plus using statement
select password from Manager where email='ivedantlodha@gmail.com'
I am getting a valid output.
Here is the output of desc Manager
Name Null? Type
----------------------------------------- --------
NAME VARCHAR2(20)
MANAGER_ID NUMBER(38)
EMAIL VARCHAR2(50)
PASSWORD VARCHAR2(30)