Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (10.2k points)

Resultset has no method for hasNext. I want to check if the resultSet has any value

is this the correct way

if (!resultSet.next() ) {

    System.out.println("no data");

}

1 Answer

0 votes
by (46k points)

That's right, initially, the ResultSet's cursor is pointing to before the first row if the initial call to next() returns invalid then there was no data in the ResultSet.

If you try this way, you may have to call beforeFirst()immediately after to reset it, since it has placed itself past the first row now.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Sep 9, 2019 in Java by Anvi (10.2k points)
0 votes
1 answer
asked Dec 6, 2020 in SQL by Appu (6.1k points)

Browse Categories

...