Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (3.4k points)
Shouldn't this be a pretty straightforward operation? However, I see there's neither a size() nor length() method.

1 Answer

0 votes
by (119k points)

You can use any one of the following methods:

SELECT COUNT(*) FROM ... query instead.

OR

int size =0;

if (rs != null) 

{

  rs.last();    // moves cursor to the last row

  size = rs.getRow(); // get row id 

}

In both cases, you don't have to loop over the entire data. 

If you want to learn Java, then enroll in this Java Certification Program by Intellipaat.

Related questions

0 votes
1 answer
0 votes
1 answer
asked Sep 9, 2019 in Java by Anvi (10.2k points)
0 votes
1 answer
0 votes
1 answer
asked Nov 23, 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

...