JDBC Pagination

Posted by Zeeshan on Stack Overflow See other posts from Stack Overflow or by Zeeshan
Published on 2010-05-05T07:58:49Z Indexed on 2010/05/05 8:18 UTC
Read the original article Hit count: 143

Filed under:
|

Hi,

I want to implement pagination using JDBC. The actual thing I want to know is "How can i get first 50 and then next 50 records from database for page 1 and 2 respectively"

My Query is Select * from data [data table contains 20,000 rows]

For page #1 I get 50 records and for page #2 I want to get next 50 records. How can I implement it efficiently in JDBC?

I have searched and found that rs.absolute(row) is the way to skip first page records but it takes some amount of time on large result sets and I don't want to bear this amount of time. Also, I don't want to use rownum and limit + offset in query because these are not good to use in query, I dont know why, still I don't want to use it in query.

Can anyone help me how to get limited ResultSet for pagination or is there any way JDBC is giving us?

© Stack Overflow or respective owner

Related posts about java-ee

Related posts about java