aspose file tools*
The moose likes JDBC and the fly likes paging Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "paging" Watch "paging" New topic
Author

paging

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I have a select statement that retrieves 1200 records and some times 10 records.. I use a vector to store the row information. When the select st returrns 1200 records the I get 500 error. where as if its less than that
maybe 40 -50 reords it works fine.

Why is this due to?
David Ulicny
Ranch Hand

Joined: Aug 04, 2004
Posts: 724
Is there any exception?


SCJP<br />SCWCD <br />ICSD(286)<br />MCP 70-216
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I get 500 error and stops at rs.next() statement. Is there something like a database can retrieve only "X" number of rows or a webpage cannot have more than particular number of rows.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30753
    
156

Shan,
There aren't any inherent size restrictions. You are probably getting the 500 error due to a timeout.

1200 records isn't that many though. Do you know how long it goes before timing out?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
This morning surprisingly everything seems to be fine. It allows me to fetch upto 3400 records.

Now I have a question. I have all these records in a Treemap . all the records are stored as object's in the treemap.
The way data is stored in treemap is

map.put(10,vector)
map.put(20,vector)


Now I would like to do paging. How Do I go about?
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30753
    
156

Shan,
What does the "10" and "20" mean? Is that the position number?

I would suggest storing the data in a List structure, like an ArrayList, to facilitate paging. Then you can use indexes to get the sublist you want to display on a given page.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
map.put(10,Vector)

means for Deptno 10 I store all the employee information in Vector.

In my report the user is allowed to select 5 deptno. I have to display the employee information of each dept.

My report looks like

Dno 10 Dept Name HR
Eno Ename
1 JOhn
2 Adam
3 Mike


Dno 20 Dept Name PAYROLL
Eno Ename
7 Jim
8 Tom
9 Mary
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30753
    
156

Shan,
Your scenario is a bit more complex that the standard paging question. And now I see why you are using a map.

When you do the paging, do you want to display a certain number of dept numbers or a certain number of rows on the page? For the former, you can use the standard paging solutions on a list of sorted keys. Then display each record in that section. For the later, you will need a counter of your own.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I would have deptno listed on top of my page like

10 20 30 40 50

By default it opens with the records of first deptno here 10.

If the records exceed 100 then in that page I need paging.
[ October 22, 2004: Message edited by: shan javan ]
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30753
    
156

Shan,
That's the standard case. You just want to page within a resultset. That resultset happens to reside in your map.

I would suggest doing a search of this and the JSP forums for "paging" to get ideas.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
shan i am thinking in another way.

you said that it is working fine now and fetching upto 3400 records. and then you mentioned that you need to sort the records accoring to departments, because you are manipulating records according to the department on your front-end UI. So, why not manipulate the records according to the departments at the back-end as well.

I think you should query just the records of the requested department and then use standard paging. it will save you in the future when there would be 100,000's of record.

what you people say?
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I now have vector of records for each deptno. I want place first next prev and last button on same page. I have no idea where to start. I saw couple of posts on paging but that didn't trigger any ideas. Can some help me with this?

BElow is the code I use to just display all the records.

Dept.jsp

First Next Prev Last ...need here


Vector v = (Vector) request.getAttribute("EMPLIST");
out.println("list size = " + v.size());
for (int i = 0; i < v.size(); i++) {
Dept_Domain domain = new Dept_Domain();
domain = (Dept_Domain) v.elementAt(i);
}

<TD align="center"><%=domain.empname%></TD>
<TD align="center"><%=domain.empdate%></TD>

}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: paging