public class SqlRowSetResultSetExtractor extends java.lang.Object implements ResultSetExtractor<SqlRowSet>
The default implementation uses a standard JDBC CachedRowSet underneath.
This means that JDBC RowSet support needs to be available at runtime:
by default, Sun's com.sun.rowset.CachedRowSetImpl
class on Java 5 and 6,
or the javax.sql.rowset.RowSetProvider
mechanism on Java 7 / JDBC 4.1.
newCachedRowSet()
,
SqlRowSet
,
JdbcTemplate.queryForRowSet(String)
,
CachedRowSet
Modifier and Type | Field and Description |
---|---|
private static java.lang.reflect.Method |
createCachedRowSet |
private static java.lang.Object |
rowSetFactory |
Constructor and Description |
---|
SqlRowSetResultSetExtractor() |
Modifier and Type | Method and Description |
---|---|
protected SqlRowSet |
createSqlRowSet(java.sql.ResultSet rs)
Create a SqlRowSet that wraps the given ResultSet,
representing its data in a disconnected fashion.
|
SqlRowSet |
extractData(java.sql.ResultSet rs)
Implementations must implement this method to process the entire ResultSet.
|
protected javax.sql.rowset.CachedRowSet |
newCachedRowSet()
Create a new CachedRowSet instance, to be populated by
the
createSqlRowSet implementation. |
private static java.lang.Object rowSetFactory
private static java.lang.reflect.Method createCachedRowSet
public SqlRowSet extractData(java.sql.ResultSet rs) throws java.sql.SQLException
ResultSetExtractor
extractData
in interface ResultSetExtractor<SqlRowSet>
rs
- ResultSet to extract data from. Implementations should
not close this: it will be closed by the calling JdbcTemplate.null
if none
(the extractor will typically be stateful in the latter case).java.sql.SQLException
- if a SQLException is encountered getting column
values or navigating (that is, there's no need to catch SQLException)protected SqlRowSet createSqlRowSet(java.sql.ResultSet rs) throws java.sql.SQLException
This implementation creates a Spring ResultSetWrappingSqlRowSet instance that wraps a standard JDBC CachedRowSet instance. Can be overridden to use a different implementation.
rs
- the original ResultSet (connected)java.sql.SQLException
- if thrown by JDBC methodsnewCachedRowSet()
,
ResultSetWrappingSqlRowSet
protected javax.sql.rowset.CachedRowSet newCachedRowSet() throws java.sql.SQLException
createSqlRowSet
implementation.
The default implementation creates a new instance of
Sun's com.sun.rowset.CachedRowSetImpl
class.
java.sql.SQLException
- if thrown by JDBC methodscreateSqlRowSet(java.sql.ResultSet)
,
CachedRowSetImpl