Here you can find the source of getRowCount(ResultSet set)
public static int getRowCount(ResultSet set) throws SQLException
//package com.java2s; //License from project: Apache License import java.sql.ResultSet; import java.sql.SQLException; public class Main { public static int getRowCount(ResultSet set) throws SQLException { int rowCount; int currentRow = set.getRow(); // Get current row rowCount = set.last() ? set.getRow() : 0; // Determine number of rows if (currentRow == 0) // If there was no current row set.beforeFirst(); // We want next() to go to first row else // If there WAS a current row set.absolute(currentRow); // Restore it return rowCount; }//from ww w .j a v a2s. co m }