This the solution for showing large result set ( i.e Paging)

Discussions

EJB design: This the solution for showing large result set ( i.e Paging)

  1. Hello All,
             I have a solution for showing large result sets. This solution is when you r using jsp to show the result of large query, and u want to show the results 5 at a time and with Next & Previous buttons, u can also give page numbers in the end too i.e 1 2 3 4 etc.
             What i actually did is that whenever somebody ask for that result set taht is large and for that i want o show 5 records per page, i forward it to a servlet which actually execute the query and store the result set in cachedrowset and also store the reference of this cachedrowset in the Http session. It then dispatch the control to a JSP with first time a variable appeneded to it named offset e.g showresult.jsp?offset=0 now i place the cursor to offset + 1 i.e 1 for the first time. Then show say 5 result onward from the offset in the end the link of Next sets the value of offset to offset+5 and previous to offset-5 and i actually used cahedrowset.absolute(offset)
    and then if(cachedrowset !=Null)
             {
             While(int i = 0; i<5;i++)
             {
              cachedrowset.next();
              //process the results
             }
             } // end of if
    And for calculating the page number i have the size method
    of cached row set that size/5 + 1 is the numbert of pages for the result set and for each link there is +5.
     
    Looking forward to disscuss this solution with u ppl.
                         Bye
                        SHOAIB AKHATAR
                         775 at nu dot edu.pk
  2. Dear sir:
      can you give me a example for more detail.
    Thanks
  3. Hi Shoaib,

     You might also want to check out the ValueListHandler Pattern
  4. Hi Shoaib,

    >
    >  You might also want to check out the ValueListHandler Pattern

    Hello Kiran,
               Thanks for information, i know the pattern u described but i think that my solution is much better if u want performance as in ValueListHandler u have to create object for the result set and then pass it say 5 at a time. This object creation process takes a much longer time than to cachedrowset approach and also if records returned are more than 5,000 then often the application server runs out of memory. And If u regard Richard Monson Heifel then he also advised to use cachedrowset.
                              thankyou
                              SHOAIB AKHTAR
  5. project to help...[ Go to top ]

    Also, look at http://valuelist.sourceforge.net
  6. Paging in J2EE: Manage Large Result Sets Efficiently


    http://www.devx.com/Java/Article/21383/1763/page/1