• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Count the numbers of rows in a resultset

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This question is very common; search the forum for "resultset count rows" to see some relevant posts.
 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic