File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Resultset Size

 
David Chan
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I check to size of the resultset or no. of row return without traversing the whole resultset?
David Chan
 
Simon Xu
Ranch Hand
Posts: 235
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can do select count (*) from .... before actually get your ResultSet.
Regards
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by David Chan:
How can I check to size of the resultset or no. of row return without traversing the whole resultset?

If you have a JDBC 2.0 scrollable result set, you should be able to go to the last row (last()) and then get the current row number (getRow()). I'm not sure if that would be more efficient than doing a count(*) query first or not - give it try and tell us what you found.
- Peter
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic