private static int getNumFetchedRows(ResultSet resultSet) {
      int numFetchedRows = 0;
      Field fi = null;

      if (resultSet instanceof SQLServerResultSet) {
         try {
            fi = SQLServerResultSet.class.getDeclaredField("rowCount");
            fi.setAccessible(true);
            numFetchedRows = (int) fi.get(resultSet);
         } catch (Exception e) {
            // ignore exception
            numFetchedRows = 0;
         }
      } else if (resultSet instanceof CsvCachedRowSetImpl) {
         numFetchedRows = ((CsvCachedRowSetImpl) resultSet).getRowCount();         
      } else if (resultSet instanceof MongoDBRowSetImpl) {         
         numFetchedRows = ((MongoDBRowSetImpl) resultSet).getRowCount();
      }

      return numFetchedRows;
   }
Get the number of rows fetched from the ResultSet using reflection.

@param resultSet the ResultSet
@return the number of rows fetched
src/main/java/org/replicadb/manager/SQLServerManager.java