package com.corej2eepatterns.dao;

// importy

public class CustomerDAO {
  . . .  

  // Utworzenie ReadOnlyRowSet, uywajc 
  // ResultSet do wykonywania zapyta
  public RowSet findCustomersRORS(CustomerTO criteria, 
      int startAtRow, int howManyRows)
      throws DAOException {

    Connection con = getConnection();
    javax.sql.RowSet rowSet = null;
    String searchSQLString = getSearchSQLString(criteria);

    try {
      con = getConnection();
      java.sql.Statement stmt = con.createStatement(. . .);
      java.sql.ResultSet rs =
          stmt.executeQuery(searchSQLString);
      rowSet = new ReadOnlyRowSet();
      rowSet.populate(rs, startAtRow, howManyRows);
    } catch (SQLException anException) {
      // obsuga wyjtku
    } finally {
      con.close();
    }
    return rowSet;
  }

  . . .  
}