Http://cheneyph.iteye.com/blog/477829
In Java, there are several methods to obtain the total number of rows of the resultset.
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 ");
}
Rowcount is the total number of rows in the resultset.
·*************************************** **************************************** **********************************
· It is very simple to obtain the total number of columns of the resultset in Java, because the resultset provides the resultsetmetadata tool class, And resultsetmetadata is a set description of the metadata of the resultset.
Java obtains the total number of columns of the resultsetCodeAs follows:
Statement stmt = con. createstatement (resultset. type_scroll_insensitive, resultset. concur_updatable );
Resultset rset = stmt.exe cutequery ("select * From yourtable ");
Resultsetmetadata rsmd = rset. getmetadata ();
Int columncount = rsmd. getcolumncount ();
Columncount is the total number of columns in the resultset.