org.apache.cayenne.access.jdbc

## Class JDBCResultIterator

- java.lang.Object
- - org.apache.cayenne.access.jdbc.JDBCResultIterator

- All Implemented Interfaces:
    ResultIterator

      public class JDBCResultIterator
      extends Object
      implements ResultIterator

  A ResultIterator over the underlying JDBC ResultSet.
  Since:
    1.2

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `closed`
    `protected boolean` | `closingConnection`
    `protected Connection` | `connection`
    `protected boolean` | `nextRow`
    `protected QueryMetadata` | `queryMetadata`
    `protected ResultSet` | `resultSet`
    `protected RowDescriptor` | `rowDescriptor`
    `protected Statement` | `statement`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JDBCResultIterator(Connection connection, Statement statement, ResultSet resultSet, RowDescriptor descriptor, QueryMetadata queryMetadata)` Creates new JDBCResultIterator that reads from provided ResultSet.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `List<?>` | `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.
    `RowDescriptor` | `getRowDescriptor()`
    `boolean` | `hasNextRow()` Returns true if there is at least one more record that can be read from the iterator.
    `boolean` | `isClosingConnection()` Returns `true` if this iterator is responsible for closing its connection, otherwise a user of the iterator must close the connection after closing the iterator.
    `Object` | `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)` Sets the `closingConnection` property.
    `void` | `skipRow()`

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

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

- - ### Field Detail

    - #### connection

          protected Connection connection

    - #### statement

          protected Statement statement

    - #### resultSet

          protected ResultSet resultSet

    - #### rowDescriptor

          protected RowDescriptor rowDescriptor

    - #### queryMetadata

          protected QueryMetadata queryMetadata

    - #### closingConnection

          protected boolean closingConnection

    - #### closed

          protected boolean closed

    - #### nextRow

          protected boolean nextRow

  - ### Constructor Detail

    - #### JDBCResultIterator

          public JDBCResultIterator(Connection connection,
                                    Statement statement,
                                    ResultSet resultSet,
                                    RowDescriptor descriptor,
                                    QueryMetadata queryMetadata)
                             throws CayenneException

      Creates new JDBCResultIterator that reads from provided ResultSet.
      Throws:
        `CayenneException`
      Since:
        3.0

  - ### Method Detail

    - #### allRows

          public List<?> allRows()
                          throws CayenneException

      Description copied from interface: `ResultIterator`
      Returns all yet unread rows from ResultSet without closing it.
      Specified by:
        `allRows` in interface `ResultIterator`
      Throws:
        `CayenneException`
      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`

    - #### nextRow

          public Object nextRow()
                         throws CayenneException

      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`
      Throws:
        `CayenneException`
      Since:
        3.0

    - #### skipRow

          public void skipRow()
                       throws CayenneException

      Specified by:
        `skipRow` in interface `ResultIterator`
      Throws:
        `CayenneException`
      Since:
        3.0

    - #### close

          public void close()
                     throws CayenneException

      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 `ResultIterator`
      Throws:
        `CayenneException`

    - #### checkNextRow

          protected void checkNextRow()
                               throws CayenneException

      Moves internal ResultSet cursor position down one row. Checks if the next row is available.
      Throws:
        `CayenneException`

    - #### isClosingConnection

          public boolean isClosingConnection()

      Returns `true` if this iterator is responsible for closing its connection, otherwise a user of the iterator must close the connection after closing the iterator.

    - #### setClosingConnection

          public void setClosingConnection(boolean flag)

      Sets the `closingConnection` property.

    - #### getRowDescriptor

          public RowDescriptor getRowDescriptor()

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