org.jfree.report.modules.misc.tablemodel
Class ScrollableResultSetTableModel
AbstractTableModel
org.jfree.report.modules.misc.tablemodel.ScrollableResultSetTableModel
- CloseableTableModel, TableModel
extends AbstractTableModel
A tableModel which is backed up by a java.sql.ResultSet. Use this to directly feed your
database data into JFreeReport. If you have trouble using this TableModel and you have
either enough memory or your query result is not huge, you may want to use
ResultSetTableModelFactory.generateDefaultTableModel (ResultSet rs)
. That
implementation will read all data from the given ResultSet and keep that data in
memory.
Use the close() function to close the ResultSet contained in this model.
void | close() - Clears the model of the current result set.
|
Class | getColumnClass(int column) - Returns the class of the resultset column.
|
String | getColumnClassName(int column) - Returns the classname of the resultset column.
|
int | getColumnCount() - Returns the number of columns in the ResultSet.
|
String | getColumnName(int column) - Returns the columnLabel or column name for the given column.
|
int | getRowCount() - Get a rowCount.
|
Object | getValueAt(int row, int column) - Returns the value of the specified row and the specified column from within the
resultset.
|
boolean | isLabelMapMode() - Returns the column name mode used to map column names into column indices.
|
void | updateResultSet(ResultSet resultset) - Updates the result set in this model with the given ResultSet object.
|
ScrollableResultSetTableModel
public ScrollableResultSetTableModel(ResultSet resultset,
boolean labelMapMode)
throws SQLException
Constructs the model.
resultset
- the result set.labelMapMode
- defines, whether to use column names or column labels to compute
the column index.
ScrollableResultSetTableModel
protected ScrollableResultSetTableModel(boolean labelMapMode)
Creates a new scrollable result set with no resultset assigned and the specified
label map mode.
labelMapMode
- defines, whether to use column names or column labels to compute
the column index.
getColumnClass
public Class getColumnClass(int column)
Returns the class of the resultset column. Returns Object.class if an error
occurred.
column
- the column index.
getColumnClassName
public String getColumnClassName(int column)
Returns the classname of the resultset column. Returns Object.class if an error
occurred.
column
- the column index.
getColumnCount
public int getColumnCount()
Returns the number of columns in the ResultSet. Returns 0 if no result set is set or
the column count could not be retrieved.
java.sql.ResultSetMetaData.getColumnCount()
getColumnName
public String getColumnName(int column)
Returns the columnLabel or column name for the given column. Whether the label or the
name is returned depends on the label map mode.
column
- the column index.
java.sql.ResultSetMetaData.getColumnLabel(int)
getRowCount
public int getRowCount()
Get a rowCount. This can be a very expensive operation on large datasets. Returns -1
if the total amount of rows is not known to the result set.
getValueAt
public Object getValueAt(int row,
int column)
Returns the value of the specified row and the specified column from within the
resultset.
row
- the row index.column
- the column index.
isLabelMapMode
public boolean isLabelMapMode()
Returns the column name mode used to map column names into column indices. If true,
then the Label is used, else the Name is used.
- true, if the column label is used for the mapping, false otherwise.
ResultSetMetaData.getColumnLabel
, ResultSetMetaData.getColumnName
updateResultSet
public void updateResultSet(ResultSet resultset)
throws SQLException
Updates the result set in this model with the given ResultSet object.
resultset
- the new result set.