• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Count the numbers of rows in a resultset

 
Chhaya Dhanani
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
how can i find the numbers of rows in a resultset?
i am using jdk2.
actually i want to display different pages depending on the number of rows..
if count is 1,display X.jsp
else if count is 10,display Y.jsp
please answer this as soon as possible
Chhaya
 
Craig Demyanovich
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question is very common; search the forum for "resultset count rows" to see some relevant posts.
 
Francois Bourgault
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use the following:
myResultSet.last();
int rowcount = myResultSet.getRow();
myResultSet.beforeFirst();
 
Francois Bourgault
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use the following:
myResultSet.last();
int rowcount = myResultSet.getRow();
myResultSet.beforeFirst();
 
Craig Demyanovich
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The limitation with your method, Francois, is that it assumes that the ResultSet is scrollable. All ResultSets that I have worked with from the various metadata classes are forward-only ResultSets. Hence, depending on the source and type of ResultSet you have, the solution to this problem must be different.
[ February 19, 2002: Message edited by: Craig Demyanovich ]
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
some points i made in a previous post regarding methods to count rows
Jamie
[ February 19, 2002: Message edited by: Jamie Robertson ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic