package com.corej2eepatterns.dao;

// importy

public class CustomerDAO {
. . .  

  // utworzenie listy obiektw transferowych i jej zwrcenie
  public List findCustomers(CustomerTO criteria)    
      throws DAOException {

    Connection con = getConnection();
    ResultSet rs = null;
    ArrayList custList = new ArrayList();
    String searchSQLString = getSearchSQLString(criteria);

    try {
      con = getConnection();
      java.sql.Statement stmt =
          con.createStatement(. . . );.
      rs = stmt.executeQuery(searchSQLString);
      while(rs.next()) {
        // utworzenie obiektu transferowego na podstawie danych z rs
        cust = new CustomerTO();
        cust.setId(rs.getString(1));
        cust.setName(rs.getString(2));
        . . . 

        // dodanie obiektu do listy
        custList.add(cust);
      }
    } catch (Exception e) {
      // obsuga wyjtku
    } finally {
      // zamknicie poczenia
    }
    return custList;
  }

  . . .  

}