• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

want to display results page by page

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 [email protected]
thanks in Adavance
Rinku
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"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.
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 [email protected]
thanks in Adavance
Rinku



------------------
Vikas Aggarwal
Technology Associate
http://www.vikinsa.com
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
I once met a man from Nantucket. He had a tiny ad
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic