org.springframework.jdbc.core
Interface ColumnExtractor
- All Known Implementing Classes:
- DefaultColumnExtractor
- public interface ColumnExtractor
Interface to be implemented by objects that know how to extract
columns from a ResultSet and ensure that they are of a given type.
Different drivers and databases may require slightly
different implementations.
This is a useful concept, although there is little requirement
for it in the framework classes in this package.
- Author:
- Rod Johnson
- Since: May 2, 2001
| Method Summary |
Object | extractColumn(String columnName, Class requiredType, ResultSet rs) Extract the given column from this row of the given ResultSet, ensuring that the
returned object is of the required type. |
Object | extractColumn(int i, Class requiredType, ResultSet rs) Extract the given column from this row of the given ResultSet, ensuring that the
returned object is of the required type. |
extractColumn
public Object extractColumn(String columnName, Class requiredType, ResultSet rs)
throws java.sql.SQLException
- Extract the given column from this row of the given ResultSet, ensuring that the
returned object is of the required type. A naive implementation of this might simply
call ResultSet.getObject(columnName). Note that if there is a fundamental mismatch between
column type and the required Java type, implementing classes are not required to succeed.
- Parameters:
- columnName - name of the column we want from the ResultSet
- requiredType - class of object we must return
- rs - ResultSet to extract the column value from
- Returns: the value of the specified column in the ResultSet as an instance of the
required type
- Throws:
- SQLException - if there is any problem getting this column value. Implementations
of this interface do not need to worry about handling such exceptions; they can
assume they will only be called by code that correctly cleans up after any SQLExceptions
extractColumn
public Object extractColumn(int i, Class requiredType, ResultSet rs)
throws java.sql.SQLException
- Extract the given column from this row of the given ResultSet, ensuring that the
returned object is of the required type. Should implement the same conversion
as extractColumn(columnName...).
- Parameters:
- i - index (from 1) of the column we want from the ResultSet
- requiredType - class of object we must return
- rs - ResultSet to extract the column value from
- Returns: the value of the specified column in the ResultSet as an instance of the
required type
- Throws:
- SQLException - if there is any problem getting this column value. Implementations
of this interface do not need to worry about handling such exceptions; they can
assume they will only be called by code that correctly cleans up after any SQLExceptions