public class JRResultSetDataSource extends Object implements JRDataSource
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.
Modifier and Type | Field and Description |
---|---|
static String |
EXCEPTION_MESSAGE_KEY_RESULT_SET_CLOB_VALUE_READ_FAILURE |
static String |
EXCEPTION_MESSAGE_KEY_RESULT_SET_COLUMN_INDEX_OUT_OF_RANGE |
static String |
EXCEPTION_MESSAGE_KEY_RESULT_SET_FIELD_VALUE_NOT_RETRIEVED |
static String |
EXCEPTION_MESSAGE_KEY_RESULT_SET_METADATA_NOT_RETRIEVED |
static String |
EXCEPTION_MESSAGE_KEY_RESULT_SET_NEXT_RECORD_NOT_RETRIEVED |
static String |
EXCEPTION_MESSAGE_KEY_RESULT_SET_UNKNOWN_COLUMN_LABEL |
static String |
EXCEPTION_MESSAGE_KEY_RESULT_SET_UNKNOWN_COLUMN_NAME |
static String |
INDEXED_COLUMN_PREFIX |
static String |
PROPERTY_FIELD_COLUMN_INDEX
Property specifying the result set column index for the dataset field.
|
static String |
PROPERTY_FIELD_COLUMN_LABEL
Property specifying the result set column label for the dataset field.
|
static String |
PROPERTY_FIELD_COLUMN_NAME
Property specifying the result set column name for the dataset field.
|
Constructor and Description |
---|
JRResultSetDataSource(JasperReportsContext jasperReportsContext,
ResultSet resultSet) |
JRResultSetDataSource(ResultSet resultSet) |
Modifier and Type | Method and Description |
---|---|
protected String |
clobToString(Clob clob) |
protected Calendar |
createFieldCalendar(JRField field) |
protected CharArrayReader |
getArrayReader(Reader reader,
long size) |
protected Calendar |
getFieldCalendar(JRField field) |
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(InputStream is,
long size) |
protected byte[] |
readBytes(Integer columnIndex) |
protected Object |
readDate(Integer columnIndex,
JRField field) |
protected Object |
readTime(Integer columnIndex,
JRField field) |
protected Object |
readTimestamp(Integer columnIndex,
JRField field) |
protected TimeZone |
resolveTimeZone(String timezoneId) |
protected Integer |
searchColumnByIndex(JRField field) |
protected Integer |
searchColumnByIndex(String index) |
protected Integer |
searchColumnByLabel(JRField field) |
protected Integer |
searchColumnByLabel(String label) |
protected Integer |
searchColumnByName(JRField field) |
protected Integer |
searchColumnByName(String name) |
void |
setReportTimeZone(TimeZone reportTimeZone)
Sets the report time zone, which is the one used to display datetime values in the report.
|
void |
setTimeZone(TimeZone timeZone,
boolean override)
Sets the default time zone to be used for retrieving date/time values from the
result set.
|
public static final String PROPERTY_FIELD_COLUMN_NAME
public static final String PROPERTY_FIELD_COLUMN_LABEL
public static final String PROPERTY_FIELD_COLUMN_INDEX
public static final String INDEXED_COLUMN_PREFIX
public static final String EXCEPTION_MESSAGE_KEY_RESULT_SET_CLOB_VALUE_READ_FAILURE
public static final String EXCEPTION_MESSAGE_KEY_RESULT_SET_COLUMN_INDEX_OUT_OF_RANGE
public static final String EXCEPTION_MESSAGE_KEY_RESULT_SET_FIELD_VALUE_NOT_RETRIEVED
public static final String EXCEPTION_MESSAGE_KEY_RESULT_SET_METADATA_NOT_RETRIEVED
public static final String EXCEPTION_MESSAGE_KEY_RESULT_SET_UNKNOWN_COLUMN_NAME
public static final String EXCEPTION_MESSAGE_KEY_RESULT_SET_UNKNOWN_COLUMN_LABEL
public static final String EXCEPTION_MESSAGE_KEY_RESULT_SET_NEXT_RECORD_NOT_RETRIEVED
public JRResultSetDataSource(JasperReportsContext jasperReportsContext, ResultSet resultSet)
public JRResultSetDataSource(ResultSet resultSet)
public boolean next() throws JRException
JRDataSource
next
in interface JRDataSource
JRException
- if any error occurs while trying to move to the next elementpublic Object getFieldValue(JRField field) throws JRException
JRDataSource
getFieldValue
in interface JRDataSource
JRException
protected Object readDate(Integer columnIndex, JRField field) throws SQLException
SQLException
protected Object readTimestamp(Integer columnIndex, JRField field) throws SQLException
SQLException
protected Object readTime(Integer columnIndex, JRField field) throws SQLException
SQLException
protected Integer searchColumnByName(JRField field) throws SQLException, JRException
SQLException
JRException
protected Integer searchColumnByName(String name) throws SQLException
SQLException
protected Integer searchColumnByLabel(JRField field) throws SQLException, JRException
SQLException
JRException
protected Integer searchColumnByLabel(String label) throws SQLException
SQLException
protected Integer searchColumnByIndex(JRField field) throws SQLException, JRException
SQLException
JRException
protected Integer searchColumnByIndex(String index) throws SQLException, JRException
SQLException
JRException
protected String clobToString(Clob clob) throws JRException
JRException
protected CharArrayReader getArrayReader(Reader reader, long size) throws IOException
IOException
protected byte[] readBytes(Integer columnIndex) throws SQLException, IOException
SQLException
IOException
protected byte[] readBytes(InputStream is, long size) throws IOException
IOException
public void setTimeZone(TimeZone timeZone, boolean override)
timeZone
- the default time zoneoverride
- whether the default time zone overrides time zones specified
as field-level propertiesJRJdbcQueryExecuterFactory.PROPERTY_TIME_ZONE
public void setReportTimeZone(TimeZone reportTimeZone)
JRJdbcQueryExecuterFactory.PROPERTY_TIME_ZONE
property
is set to REPORT_TIME_ZONE.reportTimeZone
- the time zone used to display datetime values in the reportCopyright © 2017. All rights reserved.