Skip to content

通过移动光标获取结果集条数

示例: 统计结果集总条数

//创建Statement对象
Statement stm= conn.createStatement();
stm.execute("create table test(id int identity(1,1));insert into test values(default)");
//执行结果集查询
ResultSet rs = stm.executeQuery("select * from test")
//移动光标至结果集末尾
rs.last();
//获取结果集行数
int rsCounts = rs.getRow();