Package net.sf.jasperreports.engine
Class JRResultSetDataSource
java.lang.Object
net.sf.jasperreports.engine.JRResultSetDataSource
- All Implemented Interfaces:
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.
- Author:
- Teodor Danciu (teodord@users.sourceforge.net)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringProperty specifying the result set column index for the dataset field.static final StringProperty specifying the result set column label for the dataset field.static final StringProperty specifying the result set column name for the dataset field. -
Constructor Summary
ConstructorsConstructorDescriptionJRResultSetDataSource(ResultSet resultSet) JRResultSetDataSource(JasperReportsContext jasperReportsContext, ResultSet resultSet) -
Method Summary
Modifier and TypeMethodDescriptionprotected StringclobToString(Clob clob) protected CalendarcreateFieldCalendar(JRField field) protected CharArrayReadergetArrayReader(Reader reader, long size) protected CalendargetFieldCalendar(JRField field) getFieldValue(JRField field) Gets the field value for the current position.Access the result set that this data source is based on.booleannext()Tries to position the cursor on the next element in the data source.protected byte[]readBytes(InputStream is, long size) protected byte[]protected Objectprotected Objectprotected ObjectreadTimestamp(Integer columnIndex, JRField field) protected TimeZoneresolveTimeZone(String timezoneId) protected IntegersearchColumnByIndex(String index) protected IntegersearchColumnByIndex(JRField field) protected IntegersearchColumnByLabel(String label) protected IntegersearchColumnByLabel(JRField field) protected IntegersearchColumnByName(String name) protected IntegersearchColumnByName(JRField field) voidsetReportTimeZone(TimeZone reportTimeZone) Sets the report time zone, which is the one used to display datetime values in the report.voidsetTimeZone(TimeZone timeZone, boolean override) Sets the default time zone to be used for retrieving date/time values from the result set.
-
Field Details
-
PROPERTY_FIELD_COLUMN_NAME
Property specifying the result set column name for the dataset field.- See Also:
-
PROPERTY_FIELD_COLUMN_LABEL
Property specifying the result set column label for the dataset field.- See Also:
-
PROPERTY_FIELD_COLUMN_INDEX
Property specifying the result set column index for the dataset field.- See Also:
-
INDEXED_COLUMN_PREFIX
- See Also:
-
EXCEPTION_MESSAGE_KEY_RESULT_SET_CLOB_VALUE_READ_FAILURE
- See Also:
-
EXCEPTION_MESSAGE_KEY_RESULT_SET_COLUMN_INDEX_OUT_OF_RANGE
- See Also:
-
EXCEPTION_MESSAGE_KEY_RESULT_SET_FIELD_VALUE_NOT_RETRIEVED
- See Also:
-
EXCEPTION_MESSAGE_KEY_RESULT_SET_METADATA_NOT_RETRIEVED
- See Also:
-
EXCEPTION_MESSAGE_KEY_RESULT_SET_UNKNOWN_COLUMN_NAME
- See Also:
-
EXCEPTION_MESSAGE_KEY_RESULT_SET_UNKNOWN_COLUMN_LABEL
- See Also:
-
EXCEPTION_MESSAGE_KEY_RESULT_SET_NEXT_RECORD_NOT_RETRIEVED
- See Also:
-
-
Constructor Details
-
JRResultSetDataSource
-
JRResultSetDataSource
- See Also:
-
-
Method Details
-
getResultSet
Access the result set that this data source is based on.- Returns:
- the result set used by this data source
-
next
Description copied from interface:JRDataSourceTries to position the cursor on the next element in the data source.- Specified by:
nextin interfaceJRDataSource- 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
Description copied from interface:JRDataSourceGets the field value for the current position.- Specified by:
getFieldValuein interfaceJRDataSource- Returns:
- an object containing the field value. The object type must be the field object type.
- Throws:
JRException
-
readDate
- Throws:
SQLException
-
readTimestamp
- Throws:
SQLException
-
readTime
- Throws:
SQLException
-
searchColumnByName
- Throws:
SQLExceptionJRException
-
searchColumnByName
- Throws:
SQLException
-
searchColumnByLabel
- Throws:
SQLExceptionJRException
-
searchColumnByLabel
- Throws:
SQLException
-
searchColumnByIndex
- Throws:
SQLExceptionJRException
-
searchColumnByIndex
- Throws:
SQLExceptionJRException
-
clobToString
- Throws:
JRException
-
getArrayReader
- Throws:
IOException
-
readBytes
- Throws:
SQLExceptionIOException
-
readBytes
- Throws:
IOException
-
setTimeZone
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 zoneoverride- whether the default time zone overrides time zones specified as field-level properties- See Also:
-
setReportTimeZone
Sets the report time zone, which is the one used to display datetime values in the report. The time zone is used when theJRJdbcQueryExecuterFactory.PROPERTY_TIME_ZONEproperty is set to REPORT_TIME_ZONE.- Parameters:
reportTimeZone- the time zone used to display datetime values in the report
-
getFieldCalendar
-
createFieldCalendar
-
resolveTimeZone
-