如何获得 java.sql.ResultSet 的大小? [英] How do I get the size of a java.sql.ResultSet?
本文介绍了如何获得 java.sql.ResultSet 的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这不应该是一个非常简单的操作吗?但是,我看到既没有 size()
也没有 length()
方法.
Shouldn't this be a pretty straightforward operation? However, I see there's neither a size()
nor length()
method.
推荐答案
改为使用 SELECT COUNT(*) FROM ...
查询.
或
int size =0;
if (rs != null)
{
rs.last(); // moves cursor to the last row
size = rs.getRow(); // get row id
}
在任何一种情况下,您都不必遍历整个数据.
In either of the case, you won't have to loop over the entire data.
这篇关于如何获得 java.sql.ResultSet 的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文