I am using HSQLDB in my program. I want to check if my Result Set is empty or not.
//check if empty first
if(results.next() == false){
System.out.println("empty");
}
//display results
while (results.next()) {
String data = results.getString("first_name");
//name.setText(data);
System.out.println(data);
}
The above method is not working properly. According to this post I have to call .first()
or .beforeFirst()
to rest the cursor to the first row, but .first()
and .beforFirst()
are not supported in HSQL. I also tried to add connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
but I still get the same outcome (I get the message empty and the data from the DB!!!)
What am I doing wrong here?