Class ResultSetTableModelFactory
- java.lang.Object
-
- org.jfree.report.modules.misc.tablemodel.ResultSetTableModelFactory
-
public final class ResultSetTableModelFactory extends java.lang.Object
Creates aTableModel
which is backed up by aResultSet
. If theResultSet
is scrollable, aScrollableResultSetTableModel
is created, otherwise all data is copied from theResultSet
into aDefaultTableModel
. The creation of aDefaultTableModel
can be forced if the system property"org.jfree.report.modules.misc.tablemodel.TableFactoryMode"
is set to"simple"
.- Author:
- Thomas Morgner
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
COLUMN_NAME_MAPPING_KEY
The configuration key defining how to map column names to column indices.static java.lang.String
RESULTSET_FACTORY_MODE
The 'ResultSet factory mode'.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CloseableTableModel
createTableModel(java.sql.ResultSet rs)
Creates a table model by using the givenResultSet
as the backend.CloseableTableModel
createTableModel(java.sql.ResultSet rs, boolean labelMapping)
Creates a table model by using the givenResultSet
as the backend.CloseableTableModel
generateDefaultTableModel(java.sql.ResultSet rs)
Generates aTableModel
that gets its contents filled from aResultSet
.CloseableTableModel
generateDefaultTableModel(java.sql.ResultSet rs, boolean labelMapping)
Generates aTableModel
that gets its contents filled from aResultSet
.static ResultSetTableModelFactory
getInstance()
Returns the singleton instance of the factory.
-
-
-
Field Detail
-
COLUMN_NAME_MAPPING_KEY
public static final java.lang.String COLUMN_NAME_MAPPING_KEY
The configuration key defining how to map column names to column indices.- See Also:
- Constant Field Values
-
RESULTSET_FACTORY_MODE
public static final java.lang.String RESULTSET_FACTORY_MODE
The 'ResultSet factory mode'.- See Also:
- Constant Field Values
-
-
Method Detail
-
createTableModel
public CloseableTableModel createTableModel(java.sql.ResultSet rs) throws java.sql.SQLException
Creates a table model by using the givenResultSet
as the backend. If theResultSet
is scrollable (the type is notTYPE_FORWARD_ONLY
), an instance ofScrollableResultSetTableModel
is 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 completeResultSet
into the programs memory. If theResultSet
lacks the scollable features, the data will be copied into aDefaultTableModel
and theResultSet
gets closed.- Parameters:
rs
- the result set.- Returns:
- a closeable table model.
- Throws:
java.sql.SQLException
- if there is a problem with the result set.
-
createTableModel
public CloseableTableModel createTableModel(java.sql.ResultSet rs, boolean labelMapping) throws java.sql.SQLException
Creates a table model by using the givenResultSet
as the backend. If theResultSet
is scrollable (the type is notTYPE_FORWARD_ONLY
), an instance ofScrollableResultSetTableModel
is 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 completeResultSet
into the programs memory. If theResultSet
lacks the scollable features, the data will be copied into aDefaultTableModel
and theResultSet
gets 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:
java.sql.SQLException
- if there is a problem with the result set.
-
generateDefaultTableModel
public CloseableTableModel generateDefaultTableModel(java.sql.ResultSet rs) throws java.sql.SQLException
Generates aTableModel
that gets its contents filled from aResultSet
. The column names of theResultSet
will 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:
java.sql.SQLException
- if there is a problem with the result set.
-
generateDefaultTableModel
public CloseableTableModel generateDefaultTableModel(java.sql.ResultSet rs, boolean labelMapping) throws java.sql.SQLException
Generates aTableModel
that gets its contents filled from aResultSet
. The column names of theResultSet
will 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:
java.sql.SQLException
- if there is a problem with the result set.
-
getInstance
public static ResultSetTableModelFactory getInstance()
Returns the singleton instance of the factory.- Returns:
- an instance of this factory.
-
-