com.interface21.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.
- Since:
- May 2, 2001
- Author:
- Rod Johnson
|
Method Summary |
java.lang.Object |
extractColumn(int i,
java.lang.Class requiredType,
java.sql.ResultSet rs)
Extract the given column from this row of the given ResultSet, ensuring that the
returned object is of the required type. |
java.lang.Object |
extractColumn(java.lang.String columnName,
java.lang.Class requiredType,
java.sql.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 java.lang.Object extractColumn(java.lang.String columnName,
java.lang.Class requiredType,
java.sql.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 ResultSetrequiredType - class of object we must returnrs - 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:
java.sql.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 java.lang.Object extractColumn(int i,
java.lang.Class requiredType,
java.sql.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 ResultSetrequiredType - class of object we must returnrs - 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:
java.sql.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
Rod Johnson and Spring contributors 2001-2003.