I want to know how many rows in result set after executing the particular query
ResultSet rs = ps.executeQuery();
how get the size of rs??? thanx in advance
If you just want the number of rows in the ResultSet
, you can do :
int size= 0;
if (rs != null)
{
rs.beforeFirst();
rs.last();
size = rs.getRow();
}
You need not to iterate it and count the number of rows. You can try the following easy approach
boolean b = rs.last();
int numberOfRecords = 0;
if(b){
numberOfRecords = rs.getRow();
}