Package org.apache.commons.dbutils
Class BaseResultSetHandler<T>
java.lang.Object
org.apache.commons.dbutils.BaseResultSetHandler<T>
- Type Parameters:
T
- the target type the input ResultSet will be converted to.
- All Implemented Interfaces:
ResultSetHandler<T>
Extensions of this class convert ResultSets into other objects.
According to the DRY principle (Don't Repeat Yourself), repeating
resultSet
variable inside the ResultSetHandler.handle(ResultSet)
over and over for each iteration
can get a little tedious, AbstractResultSetHandler
implicitly gives users access to
ResultSet
's methods.
NOTE This class is NOT thread safe!- Since:
- 1.6
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final boolean
absolute
(int row) protected final void
protected final void
protected final void
protected final void
protected final void
close()
protected final void
protected final int
findColumn
(String columnLabel) protected final boolean
first()
protected final ResultSet
protected final Array
getArray
(int columnIndex) protected final Array
protected final InputStream
getAsciiStream
(int columnIndex) protected final InputStream
getAsciiStream
(String columnLabel) protected final BigDecimal
getBigDecimal
(int columnIndex) protected final BigDecimal
getBigDecimal
(int columnIndex, int scale) Deprecated.protected final BigDecimal
getBigDecimal
(String columnLabel) protected final BigDecimal
getBigDecimal
(String columnLabel, int scale) Deprecated.protected final InputStream
getBinaryStream
(int columnIndex) protected final InputStream
getBinaryStream
(String columnLabel) protected final Blob
getBlob
(int columnIndex) protected final Blob
protected final boolean
getBoolean
(int columnIndex) protected final boolean
getBoolean
(String columnLabel) protected final byte
getByte
(int columnIndex) protected final byte
protected final byte[]
getBytes
(int columnIndex) protected final byte[]
protected final Reader
getCharacterStream
(int columnIndex) protected final Reader
getCharacterStream
(String columnLabel) protected final Clob
getClob
(int columnIndex) protected final Clob
protected final int
protected final String
protected final Date
getDate
(int columnIndex) protected final Date
protected final Date
protected final Date
protected final double
getDouble
(int columnIndex) protected final double
protected final int
protected final int
protected final float
getFloat
(int columnIndex) protected final float
protected final int
protected final int
getInt
(int columnIndex) protected final int
protected final long
getLong
(int columnIndex) protected final long
protected final ResultSetMetaData
protected final Reader
getNCharacterStream
(int columnIndex) protected final Reader
getNCharacterStream
(String columnLabel) protected final NClob
getNClob
(int columnIndex) protected final NClob
protected final String
getNString
(int columnIndex) protected final String
getNString
(String columnLabel) protected final Object
getObject
(int columnIndex) protected final Object
protected final Object
protected final Object
protected final Ref
getRef
(int columnIndex) protected final Ref
protected final int
getRow()
protected final RowId
getRowId
(int columnIndex) protected final RowId
protected final short
getShort
(int columnIndex) protected final short
protected final SQLXML
getSQLXML
(int columnIndex) protected final SQLXML
protected final Statement
protected final String
getString
(int columnIndex) protected final String
protected final Time
getTime
(int columnIndex) protected final Time
protected final Time
protected final Time
protected final Timestamp
getTimestamp
(int columnIndex) protected final Timestamp
getTimestamp
(int columnIndex, Calendar cal) protected final Timestamp
getTimestamp
(String columnLabel) protected final Timestamp
getTimestamp
(String columnLabel, Calendar cal) protected final int
getType()
protected final InputStream
getUnicodeStream
(int columnIndex) Deprecated.protected final InputStream
getUnicodeStream
(String columnLabel) Deprecated.protected final URL
getURL
(int columnIndex) protected final URL
protected final SQLWarning
protected abstract T
handle()
Turn theResultSet
into an Object.final T
Turn theResultSet
into an Object.protected final void
protected final boolean
protected final boolean
protected final boolean
isClosed()
protected final boolean
isFirst()
protected final boolean
isLast()
protected final boolean
isWrapperFor
(Class<?> iface) protected final boolean
last()
protected final void
protected final void
protected final boolean
next()
protected final boolean
previous()
protected final void
protected final boolean
relative
(int rows) protected final boolean
protected final boolean
protected final boolean
protected final void
setFetchDirection
(int direction) protected final void
setFetchSize
(int rows) protected final <E> E
protected final void
updateArray
(int columnIndex, Array x) protected final void
updateArray
(String columnLabel, Array x) protected final void
updateAsciiStream
(int columnIndex, InputStream x) protected final void
updateAsciiStream
(int columnIndex, InputStream x, int length) protected final void
updateAsciiStream
(int columnIndex, InputStream x, long length) protected final void
updateAsciiStream
(String columnLabel, InputStream x) protected final void
updateAsciiStream
(String columnLabel, InputStream x, int length) protected final void
updateAsciiStream
(String columnLabel, InputStream x, long length) protected final void
updateBigDecimal
(int columnIndex, BigDecimal x) protected final void
updateBigDecimal
(String columnLabel, BigDecimal x) protected final void
updateBinaryStream
(int columnIndex, InputStream x) protected final void
updateBinaryStream
(int columnIndex, InputStream x, int length) protected final void
updateBinaryStream
(int columnIndex, InputStream x, long length) protected final void
updateBinaryStream
(String columnLabel, InputStream x) protected final void
updateBinaryStream
(String columnLabel, InputStream x, int length) protected final void
updateBinaryStream
(String columnLabel, InputStream x, long length) protected final void
updateBlob
(int columnIndex, InputStream inputStream) protected final void
updateBlob
(int columnIndex, InputStream inputStream, long length) protected final void
updateBlob
(int columnIndex, Blob x) protected final void
updateBlob
(String columnLabel, InputStream inputStream) protected final void
updateBlob
(String columnLabel, InputStream inputStream, long length) protected final void
updateBlob
(String columnLabel, Blob x) protected final void
updateBoolean
(int columnIndex, boolean x) protected final void
updateBoolean
(String columnLabel, boolean x) protected final void
updateByte
(int columnIndex, byte x) protected final void
updateByte
(String columnLabel, byte x) protected final void
updateBytes
(int columnIndex, byte[] x) protected final void
updateBytes
(String columnLabel, byte[] x) protected final void
updateCharacterStream
(int columnIndex, Reader x) protected final void
updateCharacterStream
(int columnIndex, Reader x, int length) protected final void
updateCharacterStream
(int columnIndex, Reader x, long length) protected final void
updateCharacterStream
(String columnLabel, Reader reader) protected final void
updateCharacterStream
(String columnLabel, Reader reader, int length) protected final void
updateCharacterStream
(String columnLabel, Reader reader, long length) protected final void
updateClob
(int columnIndex, Reader reader) protected final void
updateClob
(int columnIndex, Reader reader, long length) protected final void
updateClob
(int columnIndex, Clob x) protected final void
updateClob
(String columnLabel, Reader reader) protected final void
updateClob
(String columnLabel, Reader reader, long length) protected final void
updateClob
(String columnLabel, Clob x) protected final void
updateDate
(int columnIndex, Date x) protected final void
updateDate
(String columnLabel, Date x) protected final void
updateDouble
(int columnIndex, double x) protected final void
updateDouble
(String columnLabel, double x) protected final void
updateFloat
(int columnIndex, float x) protected final void
updateFloat
(String columnLabel, float x) protected final void
updateInt
(int columnIndex, int x) protected final void
protected final void
updateLong
(int columnIndex, long x) protected final void
updateLong
(String columnLabel, long x) protected final void
updateNCharacterStream
(int columnIndex, Reader x) protected final void
updateNCharacterStream
(int columnIndex, Reader x, long length) protected final void
updateNCharacterStream
(String columnLabel, Reader reader) protected final void
updateNCharacterStream
(String columnLabel, Reader reader, long length) protected final void
updateNClob
(int columnIndex, Reader reader) protected final void
updateNClob
(int columnIndex, Reader reader, long length) protected final void
updateNClob
(int columnIndex, NClob nClob) protected final void
updateNClob
(String columnLabel, Reader reader) protected final void
updateNClob
(String columnLabel, Reader reader, long length) protected final void
updateNClob
(String columnLabel, NClob nClob) protected final void
updateNString
(int columnIndex, String nString) protected final void
updateNString
(String columnLabel, String nString) protected final void
updateNull
(int columnIndex) protected final void
updateNull
(String columnLabel) protected final void
updateObject
(int columnIndex, Object x) protected final void
updateObject
(int columnIndex, Object x, int scaleOrLength) protected final void
updateObject
(String columnLabel, Object x) protected final void
updateObject
(String columnLabel, Object x, int scaleOrLength) protected final void
protected final void
protected final void
protected final void
updateRowId
(int columnIndex, RowId x) protected final void
updateRowId
(String columnLabel, RowId x) protected final void
updateShort
(int columnIndex, short x) protected final void
updateShort
(String columnLabel, short x) protected final void
updateSQLXML
(int columnIndex, SQLXML xmlObject) protected final void
updateSQLXML
(String columnLabel, SQLXML xmlObject) protected final void
updateString
(int columnIndex, String x) protected final void
updateString
(String columnLabel, String x) protected final void
updateTime
(int columnIndex, Time x) protected final void
updateTime
(String columnLabel, Time x) protected final void
updateTimestamp
(int columnIndex, Timestamp x) protected final void
updateTimestamp
(String columnLabel, Timestamp x) protected final boolean
wasNull()
-
Constructor Details
-
BaseResultSetHandler
public BaseResultSetHandler()
-
-
Method Details
-
absolute
- Throws:
SQLException
-
afterLast
- Throws:
SQLException
-
beforeFirst
- Throws:
SQLException
-
cancelRowUpdates
- Throws:
SQLException
-
clearWarnings
- Throws:
SQLException
-
close
- Throws:
SQLException
-
deleteRow
- Throws:
SQLException
-
findColumn
- Throws:
SQLException
-
first
- Throws:
SQLException
-
getAdaptedResultSet
-
getArray
- Throws:
SQLException
-
getArray
- Throws:
SQLException
-
getAsciiStream
- Throws:
SQLException
-
getAsciiStream
- Throws:
SQLException
-
getBigDecimal
- Throws:
SQLException
-
getBigDecimal
@Deprecated protected final BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException Deprecated.- Throws:
SQLException
-
getBigDecimal
- Throws:
SQLException
-
getBigDecimal
@Deprecated protected final BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException Deprecated.- Throws:
SQLException
-
getBinaryStream
- Throws:
SQLException
-
getBinaryStream
- Throws:
SQLException
-
getBlob
- Throws:
SQLException
-
getBlob
- Throws:
SQLException
-
getBoolean
- Throws:
SQLException
-
getBoolean
- Throws:
SQLException
-
getByte
- Throws:
SQLException
-
getByte
- Throws:
SQLException
-
getBytes
- Throws:
SQLException
-
getBytes
- Throws:
SQLException
-
getCharacterStream
- Throws:
SQLException
-
getCharacterStream
- Throws:
SQLException
-
getClob
- Throws:
SQLException
-
getClob
- Throws:
SQLException
-
getConcurrency
- Throws:
SQLException
-
getCursorName
- Throws:
SQLException
-
getDate
- Throws:
SQLException
-
getDate
- Throws:
SQLException
-
getDate
- Throws:
SQLException
-
getDate
- Throws:
SQLException
-
getDouble
- Throws:
SQLException
-
getDouble
- Throws:
SQLException
-
getFetchDirection
- Throws:
SQLException
-
getFetchSize
- Throws:
SQLException
-
getFloat
- Throws:
SQLException
-
getFloat
- Throws:
SQLException
-
getHoldability
- Throws:
SQLException
-
getInt
- Throws:
SQLException
-
getInt
- Throws:
SQLException
-
getLong
- Throws:
SQLException
-
getLong
- Throws:
SQLException
-
getMetaData
- Throws:
SQLException
-
getNCharacterStream
- Throws:
SQLException
-
getNCharacterStream
- Throws:
SQLException
-
getNClob
- Throws:
SQLException
-
getNClob
- Throws:
SQLException
-
getNString
- Throws:
SQLException
-
getNString
- Throws:
SQLException
-
getObject
- Throws:
SQLException
-
getObject
- Throws:
SQLException
-
getObject
- Throws:
SQLException
-
getObject
- Throws:
SQLException
-
getRef
- Throws:
SQLException
-
getRef
- Throws:
SQLException
-
getRow
- Throws:
SQLException
-
getRowId
- Throws:
SQLException
-
getRowId
- Throws:
SQLException
-
getShort
- Throws:
SQLException
-
getShort
- Throws:
SQLException
-
getSQLXML
- Throws:
SQLException
-
getSQLXML
- Throws:
SQLException
-
getStatement
- Throws:
SQLException
-
getString
- Throws:
SQLException
-
getString
- Throws:
SQLException
-
getTime
- Throws:
SQLException
-
getTime
- Throws:
SQLException
-
getTime
- Throws:
SQLException
-
getTime
- Throws:
SQLException
-
getTimestamp
- Throws:
SQLException
-
getTimestamp
- Throws:
SQLException
-
getTimestamp
- Throws:
SQLException
-
getTimestamp
- Throws:
SQLException
-
getType
- Throws:
SQLException
-
getUnicodeStream
Deprecated.- Throws:
SQLException
-
getUnicodeStream
Deprecated.- Throws:
SQLException
-
getURL
- Throws:
SQLException
-
getURL
- Throws:
SQLException
-
getWarnings
- Throws:
SQLException
-
handle
Turn theResultSet
into an Object.- Returns:
- An Object initialized with
ResultSet
data - Throws:
SQLException
- if a database access error occurs- See Also:
-
handle
Turn theResultSet
into an Object.- Specified by:
handle
in interfaceResultSetHandler<T>
- Parameters:
rs
- TheResultSet
to handle. It has not been touched before being passed to this method.- Returns:
- An Object initialized with
ResultSet
data. It is legal for implementations to returnnull
if theResultSet
contained 0 rows. - Throws:
SQLException
- if a database access error occurs
-
insertRow
- Throws:
SQLException
-
isAfterLast
- Throws:
SQLException
-
isBeforeFirst
- Throws:
SQLException
-
isClosed
- Throws:
SQLException
-
isFirst
- Throws:
SQLException
-
isLast
- Throws:
SQLException
-
isWrapperFor
- Throws:
SQLException
-
last
- Throws:
SQLException
-
moveToCurrentRow
- Throws:
SQLException
-
moveToInsertRow
- Throws:
SQLException
-
next
- Throws:
SQLException
-
previous
- Throws:
SQLException
-
refreshRow
- Throws:
SQLException
-
relative
- Throws:
SQLException
-
rowDeleted
- Throws:
SQLException
-
rowInserted
- Throws:
SQLException
-
rowUpdated
- Throws:
SQLException
-
setFetchDirection
- Throws:
SQLException
-
setFetchSize
- Throws:
SQLException
-
unwrap
- Throws:
SQLException
-
updateArray
- Throws:
SQLException
-
updateArray
- Throws:
SQLException
-
updateAsciiStream
- Throws:
SQLException
-
updateAsciiStream
protected final void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException - Throws:
SQLException
-
updateAsciiStream
protected final void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException - Throws:
SQLException
-
updateAsciiStream
- Throws:
SQLException
-
updateAsciiStream
protected final void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException - Throws:
SQLException
-
updateAsciiStream
protected final void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException - Throws:
SQLException
-
updateBigDecimal
- Throws:
SQLException
-
updateBigDecimal
- Throws:
SQLException
-
updateBinaryStream
- Throws:
SQLException
-
updateBinaryStream
protected final void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException - Throws:
SQLException
-
updateBinaryStream
protected final void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException - Throws:
SQLException
-
updateBinaryStream
- Throws:
SQLException
-
updateBinaryStream
protected final void updateBinaryStream(String columnLabel, InputStream x, int length) throws SQLException - Throws:
SQLException
-
updateBinaryStream
protected final void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException - Throws:
SQLException
-
updateBlob
- Throws:
SQLException
-
updateBlob
- Throws:
SQLException
-
updateBlob
protected final void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException - Throws:
SQLException
-
updateBlob
- Throws:
SQLException
-
updateBlob
- Throws:
SQLException
-
updateBlob
protected final void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException - Throws:
SQLException
-
updateBoolean
- Throws:
SQLException
-
updateBoolean
- Throws:
SQLException
-
updateByte
- Throws:
SQLException
-
updateByte
- Throws:
SQLException
-
updateBytes
- Throws:
SQLException
-
updateBytes
- Throws:
SQLException
-
updateCharacterStream
- Throws:
SQLException
-
updateCharacterStream
protected final void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException - Throws:
SQLException
-
updateCharacterStream
protected final void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException - Throws:
SQLException
-
updateCharacterStream
- Throws:
SQLException
-
updateCharacterStream
protected final void updateCharacterStream(String columnLabel, Reader reader, int length) throws SQLException - Throws:
SQLException
-
updateCharacterStream
protected final void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException - Throws:
SQLException
-
updateClob
- Throws:
SQLException
-
updateClob
- Throws:
SQLException
-
updateClob
- Throws:
SQLException
-
updateClob
- Throws:
SQLException
-
updateClob
- Throws:
SQLException
-
updateClob
- Throws:
SQLException
-
updateDate
- Throws:
SQLException
-
updateDate
- Throws:
SQLException
-
updateDouble
- Throws:
SQLException
-
updateDouble
- Throws:
SQLException
-
updateFloat
- Throws:
SQLException
-
updateFloat
- Throws:
SQLException
-
updateInt
- Throws:
SQLException
-
updateInt
- Throws:
SQLException
-
updateLong
- Throws:
SQLException
-
updateLong
- Throws:
SQLException
-
updateNCharacterStream
- Throws:
SQLException
-
updateNCharacterStream
protected final void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException - Throws:
SQLException
-
updateNCharacterStream
- Throws:
SQLException
-
updateNCharacterStream
protected final void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException - Throws:
SQLException
-
updateNClob
- Throws:
SQLException
-
updateNClob
- Throws:
SQLException
-
updateNClob
- Throws:
SQLException
-
updateNClob
- Throws:
SQLException
-
updateNClob
- Throws:
SQLException
-
updateNClob
protected final void updateNClob(String columnLabel, Reader reader, long length) throws SQLException - Throws:
SQLException
-
updateNString
- Throws:
SQLException
-
updateNString
- Throws:
SQLException
-
updateNull
- Throws:
SQLException
-
updateNull
- Throws:
SQLException
-
updateObject
- Throws:
SQLException
-
updateObject
- Throws:
SQLException
-
updateObject
- Throws:
SQLException
-
updateObject
protected final void updateObject(String columnLabel, Object x, int scaleOrLength) throws SQLException - Throws:
SQLException
-
updateRef
- Throws:
SQLException
-
updateRef
- Throws:
SQLException
-
updateRow
- Throws:
SQLException
-
updateRowId
- Throws:
SQLException
-
updateRowId
- Throws:
SQLException
-
updateShort
- Throws:
SQLException
-
updateShort
- Throws:
SQLException
-
updateSQLXML
- Throws:
SQLException
-
updateSQLXML
- Throws:
SQLException
-
updateString
- Throws:
SQLException
-
updateString
- Throws:
SQLException
-
updateTime
- Throws:
SQLException
-
updateTime
- Throws:
SQLException
-
updateTimestamp
- Throws:
SQLException
-
updateTimestamp
- Throws:
SQLException
-
wasNull
- Throws:
SQLException
-