This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I am trying to do research on how to fetch a limited number of rows. The problem that's prompting me to do this is that I am working with Tomcat (with Sybase) and when multiple users fetch a page with a list on it, a large number of records are loaded for each user. What I am trying to achieve is fetching only the records that will fit on that page. Can this be achieved by using cursors? Please help.
This method may not be supported by all JDBC drivers. It depends on the database you may be using.
Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Joined: Apr 25, 2001
I have already tried setFetchSize(x), but that means that when you do a select statement, you will the first x number of records that show up in the resultset. How do I get to the next set of x number of records? I would like to be able to get to any point in the the resultset and pick out x number of records.
you need to ask yourself if you want to fetch all the records and display some at a time, or fetch some and display them , then fetch the next or previous set if needed. if you want to fetch all then yes the cursor will achieve this but the other records may never be requested and resources will have been wasted. if you want to get some only then you'll need to know where you last stopped. i recently fixed a similar problem, the jsp was sent 20 megs to load at once, hehe, so i had the session hold an int (offset) for the last record he saw, and if he wanted the next or previous 20 i'd setMaxRows(20) and start fetching based on the offset. theres probably a better way to do it but i couldn't think of it so thats what i did.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com