JDBC获取记录总数

2021-11-11 14:54:43
利用sql语句中的count函数获得ResultSet的总行数 Java代码 ``` String sql = "select count(*) AS c from yourtable where col = 'value'"; ResultSet rs = ps.executeQuery(sql); int rowCount = 0; if(rs.next()) { // rowCount=rs.getInt("c"); rowCount = rs.getInt(1); } ```