Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

pagination - Where

 
manish ahuja
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey everybody

I would like to know which is the best strategy for pagination whether on Java side in some Collection class or retrieve it incrementally from the database.

The problem in hand is I would be having some 50-100 rows to be displayed to the client.

Now what is better approach I retrieve all the rows from the database at one go & store it in some collection (java) object & display to the client in few chunks.

or

I retrieve from the database in small chunks & keep displaying to client as & when he requests for more.
something like this
select *
from ( select a.*, rownum rnum
from ( YOUR_QUERY_GOES_HERE -- including the order by ) a
where rownum <= MAX_ROWS )
where rnum >= MIN_ROWS

Kindly let me know about the better approach out of the two

Regards
Manish
 
Raj Chila
Ranch Hand
Posts: 128
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Manish,

Instead of writing your own Collection classes, I could suggest you to use the RowSet Implementation by sun. you could use the CachedRowSetImpl or a WebRowSetImpl depending on your needs. I have used the Libraries with JDK 1.4 and it seemed to work fine atleast for simple queries.

you can download the jdbc_rowset_tiger-1_0-fd-ri.zip from the following link -

Rowset Reference Implementation
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic