• Post Reply Bookmark Topic Watch Topic
  • New Topic

Iterate result set in JSP( again & again)

 
Kishore Dandu
Ranch Hand
Posts: 1934
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the purpose to output into different tables in a single page I need to Iterate through the result set again and again. Is it possible in JSP.
Also while outputting data based on a record I have to iterate the result set again (inside this iteration) to find similar records based on certain criteria. Is it possible.
Thanks,
Kishore.
 
Brian Glodde
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Likely you will first iterate over the resultset, index to the first record, then iterate again. I see no reason why you couldn't do it, even though it may not be the most elegant solution.
 
Kishore Dandu
Ranch Hand
Posts: 1934
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are there any books with such kind of examples.
 
Brian Glodde
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any JDBC book will illustrate how iterating over a resultset can be accomplished. Here are a few links to help you get started:
http://www.eas.asu.edu/~cse494db/IonJDBC/JDBCExample.html
http://www.onjava.com/pub/a/onjava/synd/2001/08/21/jdbc.html
http://java.sun.com/j2se/1.3/docs/api/java/sql/ResultSet.html
Hope those help!
 
Kishore Dandu
Ranch Hand
Posts: 1934
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want iteration through the result set in a JSP.
Can I copy a result set into another(this is for the purpose of iterating through the list without disturbing the present pointer on the first list)
Thanks,
Kishore.
 
Brian Glodde
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Certainly you could do something like that although, judging by what you want to do, you might have a better time loading the resultset into a Vector, then just iterating around that.
 
babu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
u can create scrollableresultsets easily by
connection.createStaement(int,int)
prarmeters of this method is availabale in ResultSet class.
but problem is all vendors are not providing support for this.
but if u got this type of resultsets u can apply methods like afterLast(),last,first() which r available in resultset class.
babu
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!