I have used a ResultSet that returns certain number of rows. My code is something like this:
ResultSet res = getData();
if(!res.next())
{
System.out.println("No Data Found");
}
while(res.next())
{
// code to display the data in the table.
}
Is there any method to check the number of rows returned by the ResultSet? Or do I have to write my own?
You could use a
do ... whileloop instead of awhileloop, so thatrs.next()is called after the loop is executed, like this:Or count the rows yourself as you’re getting them: