net.sf.jasperreports.engine

## Class JRResultSetDataSource

- java.lang.Object
- - net.sf.jasperreports.engine.JRResultSetDataSource

- All Implemented Interfaces:
    JRDataSource

      public class JRResultSetDataSource
      extends java.lang.Object
      implements JRDataSource

  This is a default implementation of the `JRDataSource` interface. Since most reports are generated using data from a relational database, JasperReports includes by default this implementation that wraps a `java.sql.ResultSet` object.

  This class can be instantiated intentionally to wrap already loaded result sets before passing them to the report-filling routines, but it is also used by the reporting engine to wrap the data retrieved from the database after having executed the report query (if present) through JDBC.

  Version:
    $Id: JRResultSetDataSource.java 7017 2014-04-15 10:18:40Z shertage $
  Author:
    Teodor Danciu (teodord@users.sourceforge.net)

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `INDEXED_COLUMN_PREFIX`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JRResultSetDataSource(JasperReportsContext jasperReportsContext, java.sql.ResultSet resultSet)`
    `JRResultSetDataSource(java.sql.ResultSet resultSet)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected java.lang.String` | `clobToString(java.sql.Clob clob)`
    `protected java.util.Calendar` | `createFieldCalendar(JRField field)`
    `protected java.io.CharArrayReader` | `getArrayReader(java.io.Reader reader, long size)`
    `protected java.util.Calendar` | `getFieldCalendar(JRField field)`
    `java.lang.Object` | `getFieldValue(JRField field)` Gets the field value for the current position.
    `boolean` | `next()` Tries to position the cursor on the next element in the data source.
    `protected byte[]` | `readBytes(java.io.InputStream is, long size)`
    `protected byte[]` | `readBytes(java.lang.Integer columnIndex)`
    `protected java.lang.Object` | `readDate(java.lang.Integer columnIndex, JRField field)`
    `protected java.lang.Object` | `readTime(java.lang.Integer columnIndex, JRField field)`
    `protected java.lang.Object` | `readTimestamp(java.lang.Integer columnIndex, JRField field)`
    `protected java.lang.Integer` | `searchColumnByLabel(java.lang.String fieldName)`
    `protected java.lang.Integer` | `searchColumnByName(java.lang.String fieldName)`
    `void` | `setTimeZone(java.util.TimeZone timeZone, boolean override)` Sets the default time zone to be used for retrieving date/time values from the result set.

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

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

- - ### Field Detail

    - #### INDEXED_COLUMN_PREFIX

          public static final java.lang.String INDEXED_COLUMN_PREFIX

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### JRResultSetDataSource

          public JRResultSetDataSource(JasperReportsContext jasperReportsContext,
                               java.sql.ResultSet resultSet)

    - #### JRResultSetDataSource

          public JRResultSetDataSource(java.sql.ResultSet resultSet)

      See Also:
        `JRResultSetDataSource(JasperReportsContext, ResultSet)`

  - ### Method Detail

    - #### next

          public boolean next()
                       throws JRException

      Description copied from interface: `JRDataSource`
      Tries to position the cursor on the next element in the data source.
      Specified by:
        `next` in interface `JRDataSource`
      Returns:
        true if there is a next record, false otherwise
      Throws:
        `JRException` - if any error occurs while trying to move to the next element

    - #### getFieldValue

          public java.lang.Object getFieldValue(JRField field)
                                         throws JRException

      Description copied from interface: `JRDataSource`
      Gets the field value for the current position.
      Specified by:
        `getFieldValue` in interface `JRDataSource`
      Returns:
        an object containing the field value. The object type must be the field object type.
      Throws:
        `JRException`

    - #### readDate

          protected java.lang.Object readDate(java.lang.Integer columnIndex,
                                  JRField field)
                                       throws java.sql.SQLException

      Throws:
        `java.sql.SQLException`

    - #### readTimestamp

          protected java.lang.Object readTimestamp(java.lang.Integer columnIndex,
                                       JRField field)
                                            throws java.sql.SQLException

      Throws:
        `java.sql.SQLException`

    - #### readTime

          protected java.lang.Object readTime(java.lang.Integer columnIndex,
                                  JRField field)
                                       throws java.sql.SQLException

      Throws:
        `java.sql.SQLException`

    - #### searchColumnByName

          protected java.lang.Integer searchColumnByName(java.lang.String fieldName)
                                                  throws java.sql.SQLException

      Throws:
        `java.sql.SQLException`

    - #### searchColumnByLabel

          protected java.lang.Integer searchColumnByLabel(java.lang.String fieldName)
                                                   throws java.sql.SQLException

      Throws:
        `java.sql.SQLException`

    - #### clobToString

          protected java.lang.String clobToString(java.sql.Clob clob)
                                           throws JRException

      Throws:
        `JRException`

    - #### getArrayReader

          protected java.io.CharArrayReader getArrayReader(java.io.Reader reader,
                                               long size)
                                                    throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### readBytes

          protected byte[] readBytes(java.lang.Integer columnIndex)
                              throws java.sql.SQLException,
                                     java.io.IOException

      Throws:
        `java.sql.SQLException`
        `java.io.IOException`

    - #### readBytes

          protected byte[] readBytes(java.io.InputStream is,
                         long size)
                              throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### setTimeZone

          public void setTimeZone(java.util.TimeZone timeZone,
                         boolean override)

      Sets the default time zone to be used for retrieving date/time values from the result set. In most cases no explicit time zone conversion would be required for retrieving date/time values from the DB, and this parameter should be null.
      Parameters:
        `timeZone` - the default time zone
        `override` - whether the default time zone overrides time zones specified as field-level properties
      See Also:
        `JRJdbcQueryExecuterFactory.PROPERTY_TIME_ZONE`

    - #### getFieldCalendar

          protected java.util.Calendar getFieldCalendar(JRField field)

    - #### createFieldCalendar

          protected java.util.Calendar createFieldCalendar(JRField field)

© 2001-2010 Jaspersoft Corporation www.jaspersoft.com