Connection        connection = borrowConnection(); PreparedStatement statement  = null; ResultSet         resultSet  = null; Iterator          answer     = null;  try { statement = connection.prepareStatement(sql);  int paramIdx = 1;  for (Iterator iter = parameters.iterator(); iter.hasNext(); paramIdx++) { statement.setObject(paramIdx, iter.next()); } resultSet = statement.executeQuery(); answer    = createResultSetIterator(model, resultSet, queryHints); return answer; } catch (SQLException ex) { throw new DynaSqlException("Error while performing a query", ex); } finally {   if (answer == null) { closeStatement(statement); returnConnection(connection); } }
return query(model, sql, (Table[])null);
    public Iterator query(Database model, String sql, Collection parameters, Table[] queryHints) throws DynaSqlException    {        Connection        connection = borrowConnection();        PreparedStatement statement  = null;        ResultSet         resultSet  = null;        Iterator          answer     = null;        try        {            statement = connection.prepareStatement(sql);            int paramIdx = 1;            for (Iterator iter = parameters.iterator(); iter.hasNext(); paramIdx++)            {                statement.setObject(paramIdx, iter.next());            }            resultSet = statement.executeQuery();            answer    = createResultSetIterator(model, resultSet, queryHints);            return answer;        }        catch (SQLException ex)        {            throw new DynaSqlException("Error while performing a query", ex);        }        finally        {            // if any exceptions are thrown, close things down            // otherwise we're leaving it open for the iterator            if (answer == null)            {                closeStatement(statement);                returnConnection(connection);            }        }    }