Package org.springframework.jdbc.core
Class SqlRowSetResultSetExtractor
- java.lang.Object
- org.springframework.jdbc.core.SqlRowSetResultSetExtractor
- All Implemented Interfaces:
ResultSetExtractor<SqlRowSet>
public class SqlRowSetResultSetExtractor extends Object implements ResultSetExtractor<SqlRowSet>
ResultSetExtractor
implementation that returns a SpringSqlRowSet
representation for each givenResultSet
.The default implementation uses a standard JDBC CachedRowSet underneath.
- Since:
- 1.2
- Author:
- Juergen Hoeller
- See Also:
newCachedRowSet()
,SqlRowSet
,JdbcTemplate.queryForRowSet(String)
,CachedRowSet
Constructor Summary
Constructors Constructor Description SqlRowSetResultSetExtractor()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected SqlRowSet
createSqlRowSet(ResultSet rs)
SqlRowSet
extractData(ResultSet rs)
Implementations must implement this method to process the entire ResultSet.protected CachedRowSet
newCachedRowSet()
Create a newCachedRowSet
instance, to be populated by thecreateSqlRowSet
implementation.
Constructor Detail
SqlRowSetResultSetExtractor
public SqlRowSetResultSetExtractor()
Method Detail
extractData
public SqlRowSet extractData(ResultSet rs) throws SQLException
Description copied from interface:ResultSetExtractor
Implementations must implement this method to process the entire ResultSet.- Specified by:
extractData
in interfaceResultSetExtractor<SqlRowSet>
- Parameters:
rs
- the ResultSet to extract data from. Implementations should not close this: it will be closed by the calling JdbcTemplate.- Returns:
- an arbitrary result object, or
null
if none (the extractor will typically be stateful in the latter case). - Throws:
SQLException
- if an SQLException is encountered getting column values or navigating (that is, there's no need to catch SQLException)
createSqlRowSet
protected SqlRowSet createSqlRowSet(ResultSet rs) throws SQLException
Create aSqlRowSet
that wraps the givenResultSet
, representing its data in a disconnected fashion.This implementation creates a Spring
ResultSetWrappingSqlRowSet
instance that wraps a standard JDBCCachedRowSet
instance. Can be overridden to use a different implementation.- Parameters:
rs
- the original ResultSet (connected)- Returns:
- the disconnected SqlRowSet
- Throws:
SQLException
- if thrown by JDBC methods- See Also:
newCachedRowSet()
,ResultSetWrappingSqlRowSet
newCachedRowSet
protected CachedRowSet newCachedRowSet() throws SQLException
Create a newCachedRowSet
instance, to be populated by thecreateSqlRowSet
implementation.The default implementation uses JDBC 4.1's
RowSetFactory
.- Returns:
- a new CachedRowSet instance
- Throws:
SQLException
- if thrown by JDBC methods- See Also:
createSqlRowSet(java.sql.ResultSet)
,RowSetProvider.newFactory()
,RowSetFactory.createCachedRowSet()