Paging
Hi All,
I'm implementing an application, where i'm picking data from MySQL database using jdbc, now this data is very large, i mean can be in millions. This much of data can't be displayed on one page. I want to implement paging system, so that i can show only 25 records on one page. The one as done in google.
Please suggest me how to do paging in java. I'm using Java Servlets and ajax. I can't use JSP's as required by the client.
Hope to get best possible help from you guys.
Thanks in Advance
# 1
You have millions of records, but you want a paging system that can display 25 per page? That's pointless. For someone to page through all of those would take a fortnight - obviously nobody is ever going to do that, so obviously this is pointless.
How about you just provide sufficient filtering that the user can get the number of records concerned down to a manageable number - maybe a hundred or even (at the outside) a few thousand?
Better yet, do some usability testing and find out what your users actually need, instead of putting some witless "solution" together that will prove unusable.
# 4
> Thanks for this valuable suggestion. Suppose i've
> only 100 or less records. Now i want to display them
> using paging. So please suggest me how to do this
> using java servlets and ajax.
Which bit are you stuck on? Presumably you don't expect a tutorial in AJAX or Servlets - so what are you finding difficulty about the record grouping?
# 5
If you're using MySQL, you can just use the LIMIT command in SQL for paging.
SELECT [whatever] FROM [wherever] WHERE [your conditions] LIMIT 0, 25
will return the first 25 records. So all you have to do is something like: -
ROW_MAX = 25;
inc = 0;
"SELECT [whatever] FROM [wherever] WHERE [your conditions] LIMIT " + inc + ", " + ROW_MAX;
<user clicks next page> inc += ROW_MAX;
"SELECT [whatever] FROM [wherever] WHERE [your conditions] LIMIT " + inc + ", " + ROW_MAX;
...and so on...