Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Number of rows returned?

 
Bloo Barton
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I get my ResultSet how can I quickly check that rows have been returned so I am not trying to access data that is possibly not there?
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Calling rs.next() would return false right away if there were no rows returned.
 
Andy Grove
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to know the number of rows before processing them, you could always issue a "SELECT COUNT(*) FROM TABLE WHERE ...." SQL statement first.
 
sunny sri
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
if you want to know the no of rows in resultset without doing any work on that,then you just give the method last() on the resultset then it goes to last row of resultset.After that you can call the method getrows() it will give the return type int (row no)then you can easily find out the no rows.
see the method currectly(getrows())in API.

sunny
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic