ResultSet rs = stmt.executeQuery("select count(*) from article where pid = " + pid);
rs.next();
int count = rs.getInt(1);
代码已贴上,假设我想从数据库中取出 pid=1 的数据的条数
当我成功执行ResultSet rs = stmt.executeQuery("select count(*) from article where pid = " + pid);之后 不就已经得到一个返回的结果集了吗?
为什么直接 int count = rs.getInt(1)这样使用不对?
这里rs.next(); 的作用是什么?不懂为什么 没有 rs.next();会报错