First, use the getRow method of the ResultSet to obtain the total number of rows of the ResultSet.
Statement stmt = con. createStatement (ResultSet. TYPE_SCROLL_INSENSITIVE, ResultSet. CONCUR_UPDATABLE );
ResultSet rset = stmt.exe cuteQuery ("select * from yourTableName ");
Rset. last ();
Int rowCount = rset. getRow (); // obtain the total number of rows in the ResultSet.
Type 2: Use the element of the cyclic ResultSet to obtain the total number of rows of the ResultSet.
ResultSet rset = stmt.exe cuteQuery ("select * from yourTableName ");
Int rowCount = 0;
While (rset. next ()){
RowCount ++;
}
RowCount is the total number of rows in the ResultSet.
Third: Use the count function in the SQL statement to obtain the total number of rows in the ResultSet.
ResultSet rset = stmt.exe cuteQuery ("select count (*) totalCount from yourTableName ");
Int rowCount = 0;
If (rset. next ()){
RowCount = rset. getInt ("totalCount ");
}