@Override public List<T> getAsListAndClose() { LinkedList<T> list = new LinkedList<T>(); while ( hasNext() ) { list.add( next() ); } close(); return list; }
@Override public Collection<T> getAsCollectionAndClose( Collection<T> collection ) { while ( hasNext() ) { collection.add( next() ); } close(); return collection; } }
@Override public T next() { if ( !hasNext() ) { throw new NoSuchElementException(); } currentRowRead = true; T element; try { element = createElement( rs ); } catch ( SQLException e ) { // try to close everything close(); // wrap as unchecked exception throw new RuntimeException( e.getMessage(), e ); } return element; }