如何获得java.sql.ResultSet的大小?这不是一个很简单的操作吗?但是,我发现没有size()也不length()方法。
3 回答

守着星空守着你
TA贡献1799条经验 获得超8个赞
SELECT COUNT(*) FROM ...
int size =0;if (rs != null) { rs.last(); // moves cursor to the last row size = rs.getRow(); // get row id }

繁星淼淼
TA贡献1775条经验 获得超11个赞
ResultSet rs = ps.executeQuery();int rowcount = 0;if (rs.last()) { rowcount = rs.getRow(); rs.beforeFirst(); // not rs.first() because the rs.next() below will move on, missing the first element}while (rs.next()) { // do your standard per row stuff}
添加回答
举报
0/150
提交
取消