aspose file tools*
The moose likes JDBC and the fly likes using setMaxRows of PreparedStatement - Paging the records ?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "using setMaxRows of PreparedStatement - Paging the records ??" Watch "using setMaxRows of PreparedStatement - Paging the records ??" New topic
Author

using setMaxRows of PreparedStatement - Paging the records ??

Jack Nicholson
Ranch Hand

Joined: Sep 07, 2002
Posts: 41
Hi,
I am trying to page the records in d/b using java.sql package.
I need 2 records on each subsequent fetch.
I got first set of records, but i could not be able to fetch next two records from d/b.
This is my program hereafter..


Thanx in advance.


Jack Nicholson
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30925
    
158

The second setMaxRows is setting it to 4-2, which is two. So you are doing the same query (first two rows) repeatedly. I don't think this can be done completely in Java because not all databases support it.
There's a good article that shows how to to it in Oracle.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
jQuery in Action, 2nd edition
 
subject: using setMaxRows of PreparedStatement - Paging the records ??