Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Re: paging large results

Thread Tools

Re: paging large results

Posts: n/a
I don't use Struts so there might be an answer there that i am not aware of.
What could be done is make a query to the database when the user ask for the
page and store it into his session:
Connection con = ...
Statement st = con.createStatement(...)
ResultSet rs = st.executeQuery(...)
rs.setFetchSize(20); // depends on the drivers
request.getSession().setAttribute("", rs);

And then retrieve the infos needed when the user ask for a page:
ResultSet rs = (ResultSet)request.getSession().getAttribute("mypa");
int page = request.getParameter("page");
for(int i=0; i<20 &&; i++) {
// Get one line of results and print it to the jsp

About the not to go to the database, you may perform your own filtering
using the already existing ResulSet object, but in some cases, it might be
faster to requery the databse with some more specific details. It depends on
such factors as the database cache and indexes it uses to get the data.
Don't forget pass the proper parameters to con.createStatement()
(resultSetType and resultSetConcurrency) to make sure that your datas are
safe and react as you want.

"srini" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> Hi,
> I am using struts freamework to develop a project. I have need to
> dispaly large results on the jsp page with search capability, I have
> to show only 20 results per page and need to have next and previous
> buttons to navigate the results that I retrived from database. I also
> need to provide the user a text box where he can enter a value (say a
> telephone number), and I sould be able to show the user only the
> record containing that field value. Is there any pattern in struts
> frame work which can provide me this and what is the best way to
> handle this situation. I need not goto the databse to get new results
> each time b'cos my database does not change.
> Thanks
> vulli

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Paging data results?? SAL ASP .Net 3 11-29-2007 03:29 PM
Combining numeric mode paging and nextPreview paging in datagrid Red ASP .Net 1 03-12-2005 11:41 PM
datagrid paging - customising paging style wh1974 ASP .Net 0 01-12-2005 03:48 PM
DataSet paging vs Datareader paging =?Utf-8?B?UGF0cmljay5PLklnZQ==?= ASP .Net 1 10-08-2004 02:13 PM
Paging Dr. Who, Paging Dr. Who... Computer Security 1 07-02-2004 08:59 PM