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:

Kafka Consumer Parallelism

Kafka Parallel Consumer Options: Key-level parallelism:  Multiple threads process the messages from a single partition in parallel while ma...