I have a problem, I want to execute query based on the condition. The concept is if the result is null, then execute another query. But when I try it, the result is an error
Illegal operation on empty result set`
My code:
String strSQL = "SELECT * FROM user WHERE userid=? AND password=? LIMIT 1;";
PreparedStatement pst=null;
pst = con.prepareStatement(strSQL);
pst.setString(1, userid);
pst.setString(2, password);
rs = pst.executeQuery();
if(rs.getString(1) == null && rs.getString(2) == null) {
String strSQL = "SELECT userid FROM user WHERE userid=?;";
}
if(rs.next())
{
yoyo yo = new yoyo();
yo.SetUserid(rs.getString(1));
yo.SetUsername(rs.getString(2));
yo.SetPosisi(rs.getString(5));
lstLogin = yo;
}