今天遇到一个奇怪的需求,顺便做一下笔记,之前没有这么写过。通过传统的java jdbc,通过ResultSet从select count(*)中获取记录数。
//获取总记录数
ResultSet rs = statement.executeQuery("select count(*) from msgInfo" );
if (rs.next())
{
ResultSet rs = statement.executeQuery("select count(*) from msgInfo" );
if (rs.next())
{
recordCount = rs.getInt(1);
}