{{theTime}}

Search This Blog

Total Pageviews

How to find the number of rows in the resultset (CountResult)

public static int getRowCount(ResultSet set) throws SQLException
{
sqlString = "select * from country";
// Create a scrollable ResultSet.
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
rs = stmt.executeQuery(sqlString);
// Point to the last row in resultset.
rs.last();
// Get the row position which is also the number of rows in the ResultSet.
int rowcount = rs.getRow();
// Reposition at the beginning of the ResultSet to take up rs.next() call.
rs.beforeFirst();
return rowcount ;
}

No comments:

Java Sequenced Collection Java Sequenced Collection The Sequenced Collection feature was introduced in Jav...