|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.afcs.warts.handlers.DataHandlerSupport
org.afcs.warts.handlers.LobDataHandlerSupport
org.afcs.warts.handlers.OracleBlobHandler
The OracleBlobHandler class extends
LobDataHandlerSupport
and handles the reading and writing of BLOB
data. The compilation and use of this code requires the availability of
Oracle's proprietary JDBC drivers -- as of release 9.2.0.3 of their drivers,
there is no way to write to BLOB columns without resorting to their
non-standard API.
The object returned by loadValue(java.sql.ResultSet, int)
, and expected by
bindValue()
and printValue()
is a
stored in BinaryDataHolder
instance.
LICENSE: This code is released to the public domain and may be used for any purpose whatsoever without permission or acknowledgment.
Constructor Summary | |
OracleBlobHandler(TableDescription tableDescription,
ColumnDescription columnDescription)
Contructs a new instance for the specified table and column. |
Method Summary | |
void |
bindNonNullValue(java.sql.PreparedStatement statement,
int variableIndex,
java.lang.Object value)
This method binds the specified non-null value (which should be a java.sql.Timestamp instance) to the specified index in the
specified statement. |
int |
getNullType()
Oracle returns the constant java.sql.Types.OTHER for BLOB
columns, and bizarrely, this can not be used when binding null values
in prepared statements. |
java.lang.Object |
loadValue(java.sql.ResultSet resultSet,
int columnIndex)
Returns a BinaryDataHolder
instance with the bytes loaded from the specified column from the specified
result set, if non-null. |
java.lang.String |
printNonNullValue(java.lang.Object value)
Returns a representation of the specified value (which should be a BinaryDataHolder instance) that
is appropriate for inclusion in a SQL script. |
protected void |
writeLobValue(java.sql.ResultSet results,
java.lang.Object newLobValue)
This method is responsible for writing the specified LOB value (which should be a BinaryDataHolder )
to the first column in the specified result set, which should contain
a newly initialized BLOB locator. |
Methods inherited from class org.afcs.warts.handlers.LobDataHandlerSupport |
postProcessBind, requiresBindPostProcessing, requiresStreamedLoading |
Methods inherited from class org.afcs.warts.handlers.DataHandlerSupport |
getColumnDescription, getTableDescription, isCharacterData, isNullHandler, loadBytesFromStream, logWrongValueTypeWarning, toString, verifyObjectIsString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.afcs.warts.handlers.DataHandler |
isCharacterData, isNullHandler, postProcessBind, requiresBindPostProcessing, requiresStreamedLoading |
Constructor Detail |
public OracleBlobHandler(TableDescription tableDescription, ColumnDescription columnDescription)
tableDescription
- The table that the handler will be handling data
for.columnDescription
- The column that this class will be processing
data for.Method Detail |
public void bindNonNullValue(java.sql.PreparedStatement statement, int variableIndex, java.lang.Object value) throws java.sql.SQLException
java.sql.Timestamp
instance) to the specified index in the
specified statement. A warning message is logged if the value is not
a Timestamp.
bindNonNullValue
in interface DataHandler
statement
- The statement to bind the value in.variableIndex
- The index of the variable to bind.value
- The value to bind to the statement.
java.sql.SQLException
- If a SQL error occurs during binding.public int getNullType()
java.sql.Types.OTHER
for BLOB
columns, and bizarrely, this can not be used when binding null values
in prepared statements. This method overrides the default behaviour
always returning java.sql.Types.BLOB
. See my post to Oracle's JDBC forum for more information.
getNullType
in interface DataHandler
getNullType
in class DataHandlerSupport
java.sql.Types.BLOB
.public java.lang.Object loadValue(java.sql.ResultSet resultSet, int columnIndex) throws java.sql.SQLException
BinaryDataHolder
instance with the bytes loaded from the specified column from the specified
result set, if non-null.
loadValue
in interface DataHandler
resultSet
- The result set to load data from.columnIndex
- The index of the column to load data from.
java.sql.SQLException
- If a SQL exception occurs while loading data.public java.lang.String printNonNullValue(java.lang.Object value)
BinaryDataHolder
instance) that
is appropriate for inclusion in a SQL script.
printNonNullValue
in interface DataHandler
value
- The object value to print.
protected void writeLobValue(java.sql.ResultSet results, java.lang.Object newLobValue) throws java.sql.SQLException
BinaryDataHolder
)
to the first column in the specified result set, which should contain
a newly initialized BLOB locator.
writeLobValue
in class LobDataHandlerSupport
results
- The result set containing the BLOB locator.newLobValue
- The new LOB value.
java.sql.SQLException
- If a SQL error occurs during update.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |