java baba java baba - 5 months ago 17
Java Question

how get length or size of Resultset in java

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

Answer

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();  
}