Class ResultSetTableModelFactory
java.lang.Object
org.jfree.report.modules.misc.tablemodel.ResultSetTableModelFactory
Creates a
TableModel which is backed up by a ResultSet. If
the ResultSet is scrollable, a ScrollableResultSetTableModel
is created, otherwise all data is copied from the ResultSet into a
DefaultTableModel.
The creation of a DefaultTableModel can be forced if the system property
"org.jfree.report.modules.misc.tablemodel.TableFactoryMode" is set to
"simple".- Author:
- Thomas Morgner
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionCreates a table model by using the givenResultSetas the backend.createTableModel(ResultSet rs, boolean labelMapping) Creates a table model by using the givenResultSetas the backend.Generates aTableModelthat gets its contents filled from aResultSet.generateDefaultTableModel(ResultSet rs, boolean labelMapping) Generates aTableModelthat gets its contents filled from aResultSet.static ResultSetTableModelFactoryReturns the singleton instance of the factory.
-
Field Details
-
COLUMN_NAME_MAPPING_KEY
The configuration key defining how to map column names to column indices.- See Also:
-
RESULTSET_FACTORY_MODE
The 'ResultSet factory mode'.- See Also:
-
-
Method Details
-
createTableModel
Creates a table model by using the givenResultSetas the backend. If theResultSetis scrollable (the type is notTYPE_FORWARD_ONLY), an instance ofScrollableResultSetTableModelis returned. This model uses the extended capabilities of scrollable resultsets to directly read data from the database without caching or the need of copying the completeResultSetinto the programs memory. If theResultSetlacks the scollable features, the data will be copied into aDefaultTableModeland theResultSetgets closed.- Parameters:
rs- the result set.- Returns:
- a closeable table model.
- Throws:
SQLException- if there is a problem with the result set.
-
createTableModel
Creates a table model by using the givenResultSetas the backend. If theResultSetis scrollable (the type is notTYPE_FORWARD_ONLY), an instance ofScrollableResultSetTableModelis returned. This model uses the extended capabilities of scrollable resultsets to directly read data from the database without caching or the need of copying the completeResultSetinto the programs memory. If theResultSetlacks the scollable features, the data will be copied into aDefaultTableModeland theResultSetgets closed.- Parameters:
rs- the result set.labelMapping- defines, whether to use column names or column labels to compute the column index.- Returns:
- a closeable table model.
- Throws:
SQLException- if there is a problem with the result set.
-
generateDefaultTableModel
Generates aTableModelthat gets its contents filled from aResultSet. The column names of theResultSetwill form the column names of the table model. Hint: To customize the names of the columns, use the SQL column aliasing (done withSELECT nativecolumnname AS "JavaColumnName" FROM ....- Parameters:
rs- the result set.- Returns:
- a closeable table model.
- Throws:
SQLException- if there is a problem with the result set.
-
generateDefaultTableModel
public CloseableTableModel generateDefaultTableModel(ResultSet rs, boolean labelMapping) throws SQLException Generates aTableModelthat gets its contents filled from aResultSet. The column names of theResultSetwill form the column names of the table model. Hint: To customize the names of the columns, use the SQL column aliasing (done withSELECT nativecolumnname AS "JavaColumnName" FROM ....- Parameters:
rs- the result set.labelMapping- defines, whether to use column names or column labels to compute the column index.- Returns:
- a closeable table model.
- Throws:
SQLException- if there is a problem with the result set.
-
getInstance
Returns the singleton instance of the factory.- Returns:
- an instance of this factory.
-