This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes retrieving data pagewise Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "retrieving data pagewise" Watch "retrieving data pagewise" New topic
Author

retrieving data pagewise

Shashank Anand
Greenhorn

Joined: Oct 30, 2008
Posts: 26
Hi all,

I need to retrieve data from mysql database using jsp and servlets and display it in pages, 5 records per page. And provide for link to next page to display next 5 records. I am using command like SELECT name,date,message FROM my_table ORDER BY date LIMIT 5 OFFSET 5 to display 5 records. Please anyone suggest me how to display the records in pages. I am using netbeans 6.5


Thanks in advance.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63354
    
  70

Since you already know about LIMIT and OFFSET you are obtaining the data in pages already. What's your specific issue?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Shashank Anand
Greenhorn

Joined: Oct 30, 2008
Posts: 26
Hi,

I want to know how to provide links to different pages with result got as above (using resultset and stored in arrays), if I am using the above code is a jsp page.



Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63354
    
  70

Links have nothing to do with resultsets. You'd simply need to keep track of what "page" you are one (perhaps in a hidden input) and increment it for "next" or decrement it for "previous".
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: retrieving data pagewise
 
It's not a secret anymore!