简体   繁体   English

分页检索大型ResultSet

[英]Paged retrieval of a large ResultSet

A database query returns a large ResultSet, and I would like to page the result, something like a cursor where I can choose how many results to retrieve and then in a next loop retrieve the remainders. 数据库查询返回一个很大的ResultSet,我想分页显示结果,就像游标一样,在这里我可以选择要检索的结果数,然后在下一个循环中检索余数。 What is the best way to do this? 做这个的最好方式是什么?

Thanks 谢谢

You may try javax.sql.rowset.CachedRowSet . 您可以尝试javax.sql.rowset.CachedRowSet

 CachedRowSet crs = CachedRowSetImpl();
 crs.setPageSize(100);
 crs.execute(conHandle);

 while(crs.nextPage()) {
  while(crs.next()) {
  }
 }

Do you want to display large ResultSet by multiple pages? 您要按多页显示较大的ResultSet吗? I think may be you can use mysql syntax LIMIT. 我认为可能是您可以使用mysql语法LIMIT。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM