The Dark Side Of A Developer

Monday, March 14, 2005

How determine the number of rows in a Java ResultSet?

Well, last week, I see the following code for determinate how many rows had a Java Resultset:

int i;

while(myResultset.next()){
i++;
}

well there is a better way to do this ... just we must use the attribute last() of a Resultset as follows:

int totalRows=0;

totalRows=myResultset.last().getRow();

easy, no?

... yes, my Master!