如何获得java.sql.ResultSet的大小? [英] How do I get the size of a java.sql.ResultSet?

查看:123
本文介绍了如何获得java.sql.ResultSet的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这不应该是一个非常简单的操作吗?但是,我看到既没有 size()也没有 length()方法。

Shouldn't this be a pretty straightforward operation? However, I see there's neither a size() nor length() method.

推荐答案

resultSet.last()后跟 resultSet.getRow()会给你行数,但这可能不是一个好主意,因为它可能意味着通过网络读取整个表并丢弃数据。改为执行 SELECT COUNT(*)FROM ... 查询。

resultSet.last() followed by resultSet.getRow() will give you the row count, but it may not be a good idea as it can mean reading the entire table over the network and throwing away the data. Do a SELECT COUNT(*) FROM ... query instead.

这篇关于如何获得java.sql.ResultSet的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆