Implementation of
DynaClass that creates an in-memory collection
of
DynaBeans representing the results of an SQL query. Once the
DynaClass instance has been created, the JDBC
ResultSet
and
Statement on which it is based can be closed, and the
underlying
Connection can be returned to its connection pool
(if you are using one).
The normal usage pattern is something like:
Connection conn = ...; // Acquire connection from pool
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT ...");
RowSetDynaClass rsdc = new RowSetDynaClass(rs);
rs.close();
stmt.close();
...; // Return connection to pool
List rows = rsdc.getRows();
...; // Process the rows as desired
Each column in the result set will be represented as a
DynaBean
property of the corresponding name (optionally forced to lower case
for portability). There will be one
DynaBean in the
List returned by
getRows() for each
row in the original
ResultSet.
In general, instances of
RowSetDynaClass can be serialized
and deserialized, which will automatically include the list of
DynaBeans representing the data content. The only exception
to this rule would be when the underlying property values that were
copied from the
ResultSet originally cannot themselves
be serialized. Therefore, a
RowSetDynaClass makes a very
convenient mechanism for transporting data sets to remote Java-based
application components.
RowSetDynaClass
public RowSetDynaClass(ResultSet resultSet)
throws SQLException Construct a new
RowSetDynaClass for the specified
ResultSet. The property names corresponding
to column names in the result set will be lower cased.
resultSet - The result set to be wrapped
RowSetDynaClass
public RowSetDynaClass(ResultSet resultSet,
boolean lowerCase)
throws SQLException Construct a new
RowSetDynaClass for the specified
ResultSet. The property names corresponding
to the column names in the result set will be lower cased or not,
depending on the specified
lowerCase value.
If
limit is not less than 0, max
limit
number of rows will be copied into the resultset.
resultSet - The result set to be wrappedlowerCase - Should property names be lower cased?
RowSetDynaClass
public RowSetDynaClass(ResultSet resultSet,
boolean lowerCase,
int limit)
throws SQLException Construct a new
RowSetDynaClass for the specified
ResultSet. The property names corresponding
to the column names in the result set will be lower cased or not,
depending on the specified
lowerCase value.
WARNING - If you specify
false
for
lowerCase, the returned property names will
exactly match the column names returned by your JDBC driver.
Because different drivers might return column names in different
cases, the property names seen by your application will vary
depending on which JDBC driver you are using.
resultSet - The result set to be wrappedlowerCase - Should property names be lower cased?
RowSetDynaClass
public RowSetDynaClass(ResultSet resultSet,
int limit)
throws SQLException Construct a new
RowSetDynaClass for the specified
ResultSet. The property names corresponding
to column names in the result set will be lower cased.
If
limit is not less than 0, max
limit
number of rows will be copied into the list.
resultSet - The result set to be wrappedlimit - The maximum for the size of the result.