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 booleanabsolute(int row) protected final voidprotected final voidprotected final voidprotected final voidprotected final voidclose()protected final voidprotected final intfindColumn(String columnLabel) protected final booleanfirst()protected final ResultSetprotected final ArraygetArray(int columnIndex) protected final Arrayprotected final InputStreamgetAsciiStream(int columnIndex) protected final InputStreamgetAsciiStream(String columnLabel) protected final BigDecimalgetBigDecimal(int columnIndex) protected final BigDecimalgetBigDecimal(int columnIndex, int scale) Deprecated.protected final BigDecimalgetBigDecimal(String columnLabel) protected final BigDecimalgetBigDecimal(String columnLabel, int scale) Deprecated.protected final InputStreamgetBinaryStream(int columnIndex) protected final InputStreamgetBinaryStream(String columnLabel) protected final BlobgetBlob(int columnIndex) protected final Blobprotected final booleangetBoolean(int columnIndex) protected final booleangetBoolean(String columnLabel) protected final bytegetByte(int columnIndex) protected final byteprotected final byte[]getBytes(int columnIndex) protected final byte[]protected final ReadergetCharacterStream(int columnIndex) protected final ReadergetCharacterStream(String columnLabel) protected final ClobgetClob(int columnIndex) protected final Clobprotected final intprotected final Stringprotected final DategetDate(int columnIndex) protected final Dateprotected final Dateprotected final Dateprotected final doublegetDouble(int columnIndex) protected final doubleprotected final intprotected final intprotected final floatgetFloat(int columnIndex) protected final floatprotected final intprotected final intgetInt(int columnIndex) protected final intprotected final longgetLong(int columnIndex) protected final longprotected final ResultSetMetaDataprotected final ReadergetNCharacterStream(int columnIndex) protected final ReadergetNCharacterStream(String columnLabel) protected final NClobgetNClob(int columnIndex) protected final NClobprotected final StringgetNString(int columnIndex) protected final StringgetNString(String columnLabel) protected final ObjectgetObject(int columnIndex) protected final Objectprotected final Objectprotected final Objectprotected final RefgetRef(int columnIndex) protected final Refprotected final intgetRow()protected final RowIdgetRowId(int columnIndex) protected final RowIdprotected final shortgetShort(int columnIndex) protected final shortprotected final SQLXMLgetSQLXML(int columnIndex) protected final SQLXMLprotected final Statementprotected final StringgetString(int columnIndex) protected final Stringprotected final TimegetTime(int columnIndex) protected final Timeprotected final Timeprotected final Timeprotected final TimestampgetTimestamp(int columnIndex) protected final TimestampgetTimestamp(int columnIndex, Calendar cal) protected final TimestampgetTimestamp(String columnLabel) protected final TimestampgetTimestamp(String columnLabel, Calendar cal) protected final intgetType()protected final InputStreamgetUnicodeStream(int columnIndex) Deprecated.protected final InputStreamgetUnicodeStream(String columnLabel) Deprecated.protected final URLgetURL(int columnIndex) protected final URLprotected final SQLWarningprotected abstract Thandle()Turn theResultSetinto an Object.final TTurn theResultSetinto an Object.protected final voidprotected final booleanprotected final booleanprotected final booleanisClosed()protected final booleanisFirst()protected final booleanisLast()protected final booleanisWrapperFor(Class<?> iface) protected final booleanlast()protected final voidprotected final voidprotected final booleannext()protected final booleanprevious()protected final voidprotected final booleanrelative(int rows) protected final booleanprotected final booleanprotected final booleanprotected final voidsetFetchDirection(int direction) protected final voidsetFetchSize(int rows) protected final <E> Eprotected final voidupdateArray(int columnIndex, Array x) protected final voidupdateArray(String columnLabel, Array x) protected final voidupdateAsciiStream(int columnIndex, InputStream x) protected final voidupdateAsciiStream(int columnIndex, InputStream x, int length) protected final voidupdateAsciiStream(int columnIndex, InputStream x, long length) protected final voidupdateAsciiStream(String columnLabel, InputStream x) protected final voidupdateAsciiStream(String columnLabel, InputStream x, int length) protected final voidupdateAsciiStream(String columnLabel, InputStream x, long length) protected final voidupdateBigDecimal(int columnIndex, BigDecimal x) protected final voidupdateBigDecimal(String columnLabel, BigDecimal x) protected final voidupdateBinaryStream(int columnIndex, InputStream x) protected final voidupdateBinaryStream(int columnIndex, InputStream x, int length) protected final voidupdateBinaryStream(int columnIndex, InputStream x, long length) protected final voidupdateBinaryStream(String columnLabel, InputStream x) protected final voidupdateBinaryStream(String columnLabel, InputStream x, int length) protected final voidupdateBinaryStream(String columnLabel, InputStream x, long length) protected final voidupdateBlob(int columnIndex, InputStream inputStream) protected final voidupdateBlob(int columnIndex, InputStream inputStream, long length) protected final voidupdateBlob(int columnIndex, Blob x) protected final voidupdateBlob(String columnLabel, InputStream inputStream) protected final voidupdateBlob(String columnLabel, InputStream inputStream, long length) protected final voidupdateBlob(String columnLabel, Blob x) protected final voidupdateBoolean(int columnIndex, boolean x) protected final voidupdateBoolean(String columnLabel, boolean x) protected final voidupdateByte(int columnIndex, byte x) protected final voidupdateByte(String columnLabel, byte x) protected final voidupdateBytes(int columnIndex, byte[] x) protected final voidupdateBytes(String columnLabel, byte[] x) protected final voidupdateCharacterStream(int columnIndex, Reader x) protected final voidupdateCharacterStream(int columnIndex, Reader x, int length) protected final voidupdateCharacterStream(int columnIndex, Reader x, long length) protected final voidupdateCharacterStream(String columnLabel, Reader reader) protected final voidupdateCharacterStream(String columnLabel, Reader reader, int length) protected final voidupdateCharacterStream(String columnLabel, Reader reader, long length) protected final voidupdateClob(int columnIndex, Reader reader) protected final voidupdateClob(int columnIndex, Reader reader, long length) protected final voidupdateClob(int columnIndex, Clob x) protected final voidupdateClob(String columnLabel, Reader reader) protected final voidupdateClob(String columnLabel, Reader reader, long length) protected final voidupdateClob(String columnLabel, Clob x) protected final voidupdateDate(int columnIndex, Date x) protected final voidupdateDate(String columnLabel, Date x) protected final voidupdateDouble(int columnIndex, double x) protected final voidupdateDouble(String columnLabel, double x) protected final voidupdateFloat(int columnIndex, float x) protected final voidupdateFloat(String columnLabel, float x) protected final voidupdateInt(int columnIndex, int x) protected final voidprotected final voidupdateLong(int columnIndex, long x) protected final voidupdateLong(String columnLabel, long x) protected final voidupdateNCharacterStream(int columnIndex, Reader x) protected final voidupdateNCharacterStream(int columnIndex, Reader x, long length) protected final voidupdateNCharacterStream(String columnLabel, Reader reader) protected final voidupdateNCharacterStream(String columnLabel, Reader reader, long length) protected final voidupdateNClob(int columnIndex, Reader reader) protected final voidupdateNClob(int columnIndex, Reader reader, long length) protected final voidupdateNClob(int columnIndex, NClob nClob) protected final voidupdateNClob(String columnLabel, Reader reader) protected final voidupdateNClob(String columnLabel, Reader reader, long length) protected final voidupdateNClob(String columnLabel, NClob nClob) protected final voidupdateNString(int columnIndex, String nString) protected final voidupdateNString(String columnLabel, String nString) protected final voidupdateNull(int columnIndex) protected final voidupdateNull(String columnLabel) protected final voidupdateObject(int columnIndex, Object x) protected final voidupdateObject(int columnIndex, Object x, int scaleOrLength) protected final voidupdateObject(String columnLabel, Object x) protected final voidupdateObject(String columnLabel, Object x, int scaleOrLength) protected final voidprotected final voidprotected final voidprotected final voidupdateRowId(int columnIndex, RowId x) protected final voidupdateRowId(String columnLabel, RowId x) protected final voidupdateShort(int columnIndex, short x) protected final voidupdateShort(String columnLabel, short x) protected final voidupdateSQLXML(int columnIndex, SQLXML xmlObject) protected final voidupdateSQLXML(String columnLabel, SQLXML xmlObject) protected final voidupdateString(int columnIndex, String x) protected final voidupdateString(String columnLabel, String x) protected final voidupdateTime(int columnIndex, Time x) protected final voidupdateTime(String columnLabel, Time x) protected final voidupdateTimestamp(int columnIndex, Timestamp x) protected final voidupdateTimestamp(String columnLabel, Timestamp x) protected final booleanwasNull()
-
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 theResultSetinto an Object.- Returns:
- An Object initialized with
ResultSetdata - Throws:
SQLException- if a database access error occurs- See Also:
-
handle
Turn theResultSetinto an Object.- Specified by:
handlein interfaceResultSetHandler<T>- Parameters:
rs- TheResultSetto handle. It has not been touched before being passed to this method.- Returns:
- An Object initialized with
ResultSetdata. It is legal for implementations to returnnullif theResultSetcontained 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
-