org.apache.cayenne.access.jdbc

## Class JDBCResultIterator<T>

- java.lang.Object
- - org.apache.cayenne.access.jdbc.JDBCResultIterator<T>

- All Implemented Interfaces:
    AutoCloseable, Iterable<T>, ResultIterator<T>

      public class JDBCResultIterator<T>
      extends Object
      implements ResultIterator<T>

  A ResultIterator over the underlying JDBC ResultSet.
  Since:
    1.2

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `closed`
    `protected boolean` | `nextRow`
    `protected ResultSet` | `resultSet`
    `protected Statement` | `statement`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JDBCResultIterator(Statement statement, ResultSet resultSet, RowReader<T> rowReader)` Creates new JDBCResultIterator that reads from provided ResultSet.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `List<T>` | `allRows()` Returns all yet unread rows from ResultSet without closing it.
    `protected void` | `checkNextRow()` Moves internal ResultSet cursor position down one row.
    `void` | `close()` Closes ResultIterator and associated ResultSet.
    `boolean` | `hasNextRow()` Returns true if there is at least one more record that can be read from the iterator.
    `boolean` | `isClosingConnection()` Deprecated. since 4.0 always returns false. Connection closing is outside the scope of this iterator. See `ConnectionAwareResultIterator` for a replacement.
    `Iterator<T>` | `iterator()`
    `T` | `nextRow()` Returns the next result row that is, depending on the query, may be a scalar value, a DataRow, or an Object[] array containing a mix of scalars and DataRows.
    `void` | `setClosingConnection(boolean flag)` Deprecated. since 4.0 does nothing. Connection closing is outside the scope of this iterator. See `ConnectionAwareResultIterator` for a replacement.
    `void` | `skipRow()` Goes past current row.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach, spliterator`

- - ### Field Detail

    - #### statement

          protected Statement statement

    - #### resultSet

          protected ResultSet resultSet

    - #### closed

          protected boolean closed

    - #### nextRow

          protected boolean nextRow

  - ### Constructor Detail

    - #### JDBCResultIterator

          public JDBCResultIterator(Statement statement,
                                    ResultSet resultSet,
                                    RowReader<T> rowReader)

      Creates new JDBCResultIterator that reads from provided ResultSet.
      Since:
        4.0

  - ### Method Detail

    - #### iterator

          public Iterator<T> iterator()

      Specified by:
        `iterator` in interface `Iterable<T>`
      Since:
        4.0

    - #### allRows

          public List<T> allRows()

      Description copied from interface: `ResultIterator`
      Returns all yet unread rows from ResultSet without closing it.
      Specified by:
        `allRows` in interface `ResultIterator<T>`
      Since:
        3.0

    - #### hasNextRow

          public boolean hasNextRow()

      Returns true if there is at least one more record that can be read from the iterator.
      Specified by:
        `hasNextRow` in interface `ResultIterator<T>`

    - #### nextRow

          public T nextRow()

      Description copied from interface: `ResultIterator`
      Returns the next result row that is, depending on the query, may be a scalar value, a DataRow, or an Object[] array containing a mix of scalars and DataRows.
      Specified by:
        `nextRow` in interface `ResultIterator<T>`
      Since:
        3.0

    - #### skipRow

          public void skipRow()

      Description copied from interface: `ResultIterator`
      Goes past current row. If the row is not needed, this may save some time on data conversion.
      Specified by:
        `skipRow` in interface `ResultIterator<T>`
      Since:
        3.0

    - #### close

          public void close()
                     throws NoSuchElementException

      Closes ResultIterator and associated ResultSet. This method must be called explicitly when the user is finished processing the records. Otherwise unused database resources will not be released properly.
      Specified by:
        `close` in interface `AutoCloseable`
      Specified by:
        `close` in interface `ResultIterator<T>`
      Throws:
        `NoSuchElementException`

    - #### checkNextRow

          protected void checkNextRow()

      Moves internal ResultSet cursor position down one row. Checks if the next row is available.

    - #### isClosingConnection

          @Deprecated
          public boolean isClosingConnection()

      Deprecated. since 4.0 always returns false. Connection closing is outside the scope of this iterator. See `ConnectionAwareResultIterator` for a replacement.

    - #### setClosingConnection

          @Deprecated
          public void setClosingConnection(boolean flag)

      Deprecated. since 4.0 does nothing. Connection closing is outside the scope of this iterator. See `ConnectionAwareResultIterator` for a replacement.
      Sets the `closingConnection` property.

Copyright © 2001–2018 Apache Cayenne. All rights reserved.