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.
// 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.
return rowcount ;

No comments:

ImportError: cannot import name 'soft_unicode' from 'markupsafe'

Check the markupsafe version.  To fix the problem install 2.0.1 pip install markupsafe==2.0.1