I use PostgreSQL and you can do something like:
SELECT * FROM my_table LIMIT 25 OFFSET 25
which would return 25 rows starting with the 25th row in the result set.
mySQL has something similar I believe which is something like:
SELECT * ... LIMIT 5,10
where 5 and 10 are an upper and lower bounds.
Using these database features means you only need to keep track of where a particular user is in the cursor as 2 ints.
Like
cursor_start = 10
cursor_end = cursor_start + 25
Then you could have forward and backward links that just call the servlet and add or subtract from those cursor integers.
Much easier and a lot less memory then trying to have 40,000 rows in memory for each user. That can easily get out of hand if you have more than a couple of users.
Also, you using LIMIT you can have a drop down menu on your search form that sets the limit so they can retrieve 10, 20, 50, 100, 1000 or whatever terms you want to show the user.
hope this helps
Mike
On Monday, December 23, 2002, at 03:09 AM, Max Ischenko wrote:
Hi.
I have a servlet which prompts user for some values, then
search the database using entered keys and the display the result back
to the user. I want to break results into pieces so it would load
more quickly and reduce server loading (generating HTML from 3000
records take quite a few time).
Currently, it's done as this:
- select servlet accepts input keys, runs a SQL SELECT, stores returned
SQL cursor to the session and redirects to browser servlet.
- browser servlet uses c.fetchmany() to get next chunk of data and
display it. The 'Next' button does another c.fetchmany() and redirects
to itself.
These scheme is ugly and has drawbacks. Does someone know a better
solution?
Main problems are:
- can't reliably determine when cursor is no longer needed to close it
- can't browse backward (also user can press Back button)
PS: Btw, how can I put a link into HTML page to get back (like
pressing Back button)? I vaguelly recall that it should be some magic js
spell.
--
Bst rgrds, M.A.X.: Mechanical Artificial Xenomorph.
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss
------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Webware-discuss mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/webware-discuss
