This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Record Navigation  RSS feed

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You r fetch ing some records from the data base usually there will be around 100 records its collected ? its going to disply that records ?
It can display all the records in a single page

I need only 20 recors to disply in the page and the remaining in next pages ?

What ur going to do to display that logic ?

I know that thru JDBC we can navigate, but i want to know is there any other possibility.
 
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The most efficient way to do this is, if you only want one page of data (e.g. 20 records) then only select one page of data from the database.

In order for this to work you need to:
  • limit the number of rows, returned by your DB query, to the page size (*)
  • retrieve the results in a consistent order, ideally by unique key
  • note the unique keys of the first and last records in the page


  • If you want the next page you select rows where your unique key is greater than that of the last record on current page. Guess what you do if you want the previous page!

    (*) This may not be possible on all RDBMS but MS SQL Server has the "TOP n" option; Sybase has SET ROWCOUNT n; and Oracle has the rownum pseudo-column (e.g. WHERE rownum <= n). These are not without their issues, however. Strangely, Mickeysoft has the best implementation here.

    The advantage of this approach becomes particularly apparent when you have, say, 50,000 rows on the database and your page size is 100. You really don't want to pull 50,000 matching rows out of the database and into Java (memory) just to take the top 100 to display in your web page or app GUI and then discard the lot.

    I've seen this kind of implementation (the inefficient one) numerous times on Enterprise systems. It's quite often a major contributing factor to poor user perception of system performance (e.g. their searches seem to take forever).

    Unfortunately I don't have an example implementation I can show you.

    Jules
     
    Author and ninkuma
    Marshal
    Posts: 66801
    168
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    manish basotia,

    JavaRanch is a community of people from all over the world, many of who are not native English speakers. While using abbreviations like "u" instead of spelling out "you" is convenient when text messaging your friends on a cell phone or in a chat room, it presents an extra challenge to those that are already struggling with English. Additionally, such shortcuts may confound automated translation tools that patrons of the Ranch may be making use of.

    I would like to ask for your help in making the content of JavaRanch a little easier to read for everybody that visits here by not using such abbreviations.

    thanks,
    bear
    JSP Forum Bartender
     
    It is sorta covered in the JavaRanch Style Guide.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!