• Post Reply Bookmark Topic Watch Topic
  • New Topic

Retrieving the records in an iterative manner in java  RSS feed

 
Rithanya Laxmi
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a table in database and it contains thousands of records. I want to retrieve 50 records each time and display in JSP page . If the user clicks next button i have to get 51 and 100 records (i.e again 50 records) and display in JSP page , like this if user clicks next btn number of times each time i have to retrieve 50 records from table and i have to display.Any help on this please? if i use where clause in query some thing like: where id between (count-50) and count ; always doesn't return 50 records each time because if some records are missed in the range . Please let me know how we can go about it.

Thanks.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depending on your database server this can be very simple or quite tricky. MySQL for instance has the LIMIT keyword that can take not just a number of records, but also the starting index. In Oracle you must use ROWNUMBER (I can never quite remember how it works), and SQL Server probably has its own way of doing it (it has TOP x but setting the start is a bit trickier).
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
These are just a couple of the searches you can perform to find a number of good suggested solutions:

implementing paging of search results in sql server
implementing paging of search results in oracle
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!