permaculture playing cards*
The moose likes Servlets and the fly likes want to display results page by page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "want to display results page by page" Watch "want to display results page by page" New topic
Author

want to display results page by page

Rinku
Greenhorn

Joined: Jun 12, 2001
Posts: 2
Dear sir,
i want to display 10 records per page from my data base
usinf JSP technology
i want to know, can i write any sql query for that or i have write seprate coding .
pls do send any coding you have that in this mail id rinkuraj@yahoo.com
thanks in Adavance
Rinku
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
"Rinku",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.
Thanks.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Raja Shekhar
Ranch Hand

Joined: Apr 02, 2001
Posts: 49
Hi !!

There is no Query to display 10 records at a time..
Fetch all records...

and manage the 10 records...per ..page in JSP page...
Seeya

Raj
vikinsa
Ranch Hand

Joined: Apr 18, 2001
Posts: 46
Take the problem like this way....
1. Start a counter..
int intCount=0;
2. Prepare a query and Fetch the resultset
String query="select name from emp";
ResultSet rs=stmt.executeQuery(query);
3. Retrive the values from the result set

while(rs.next())
{
String name=rs.getString("name");
if(count<10)
{
vctVector.addElement(name);
}
count++;
}

5. use vector as data source.
6. In the next ietration update the initial value of count to 10 and the value in the if loop to 20. This can be done dynamically.
Originally posted by Rinku:
Dear sir,
i want to display 10 records per page from my data base
usinf JSP technology
i want to know, can i write any sql query for that or i have write seprate coding .
pls do send any coding you have that in this mail id rinkuraj@yahoo.com
thanks in Adavance
Rinku


------------------
Vikas Aggarwal
Technology Associate
http://www.vikinsa.com


Vikas Aggarwal<BR>Technology Associate<BR>http://www.vikinsa.com
Deepak B
Greenhorn

Joined: Jun 19, 2001
Posts: 17
Dear vikinsa
The solution u r givan for ritu problem will work with small amount of data but when u are acsseing huge data (may be 50000 or more than that) then u can't store data in to vector or collction, so how can i display records page by page.With ResultSet.

Thnx
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Originally posted by Raja Shekhar:
There is no Query to display 10 records at a time..

Sure there is. To display records n through m for a query:
Standard SQL-92:
SELECT *
FROM tables a
WHERE whereclause AND
  (SELECT COUNT(*)
   FROM tables b
   WHERE whereclause AND
   b.orderby_fields < a.orderby_fields)
  BETWEEN n AND m
ORDER BY orderby_fields
Oracle:
SELECT *
FROM tables
WHERE whereclause AND
  ROWNUM BETWEEN n AND m
ORDER BY orderby_fields
- Peter
 
Don't get me started about those stupid light bulbs.
 
subject: want to display results page by page