ResultSet next() returns false Yet Tuples Present
Please help me figure out what could be going on.I am using Oracle thin driver and PreparedStatement.
Code:
public boolean aunthenticate1(Connection conn,String username,String password) throws SQLException{
PreparedStatement st2 = null;
try{
String uquery = "Select username,password from mjzeko.users where username= ? AND password= ? ";
st2=conn.prepareStatement(uquery);
st2.setString(1, username);
st2.setString(2, password);
st2.executeQuery();
ResultSet res =st2.getResultSet();
System.out.println("2222");
//boolean t=res.next();
System.out.print(res.getRow());
int count=0;
while (res.next()){
System.out.print("res.getString(1)");
count++;
System.out.print(count);
}
if(count > 0)
return true;
else {
System.out.print(count);
return false;
}
}
catch(Exception ex)
{
ex.printStackTrace();
System.out.print("This is where I end up");
ex.getMessage();
ex.getCause();
return false;
}
finally{
st2.close();
}
}
Thanks
ResultSet next() Returns false Yet Tuples Present -CODE OUTPUT
mtyoung thanks for the reply.The code outputs
2222
00 //first 0=getRow() 0=count
falsefalse //one from return and the last one from authenticate1()
Thanks