|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
The DataHandler interface defines a set of methods that must be implemented by a class that is to be responsible for reading and writing a specific type of data from the database.
LICENSE: This code is released to the public domain and may be used for any purpose whatsoever without permission or acknowledgment.
Method Summary | |
void |
bindNonNullValue(java.sql.PreparedStatement statement,
int variableIndex,
java.lang.Object value)
The implementation of this method in concrete subclasses should bind the specified non-null value to the specified index in the specified statement. |
int |
getNullType()
Returns the constant from java.sql.Types that should be used
to bind null values in prepared-statements. |
boolean |
isCharacterData()
Returns true if the current column contains character data, and should therefore be loaded when performing non-ascii character scanning on a table. |
boolean |
isNullHandler()
Returns true if the implementation is the "Null handler", which is used when the DataHandlerFactory cannot construct an appropriate
handler for a specific column type. |
java.lang.Object |
loadValue(java.sql.ResultSet resultSet,
int columnIndex)
This method is responsible for constructing and returning an object from the specified column of the specified result set. |
void |
postProcessBind(java.sql.Connection connection,
java.util.List primaryKeyValues,
java.lang.Object value)
This method is called when requiresBindPostProcessing() returns true
to finish writing data to the database for which simple binding isn't
sufficient. |
java.lang.String |
printNonNullValue(java.lang.Object value)
This method should return a representation of the specified value that is appropriate for inclusion in a SQL script. |
boolean |
requiresBindPostProcessing()
Returns true if writing of the data handled by this handler requires additional post-processing of the bind step. |
boolean |
requiresStreamedLoading()
Returns true if the loading of this data requires streaming outside the standard result set, which is true for LOB data. |
Method Detail |
public void bindNonNullValue(java.sql.PreparedStatement statement, int variableIndex, java.lang.Object value) throws java.sql.SQLException
statement
- The statement to bind the value in.variableIndex
- The index of the variable to bind.value
- The value to bind to the statement. This value should
be of the appropriate type for the data handler subclass.
java.sql.SQLException
- If a SQL error occurs during binding.public int getNullType()
java.sql.Types
that should be used
to bind null values in prepared-statements. Normally, one would hope that
you could just use the type returned by analysis of column metadata, but
in some cases, like Oracle LOBs, this isn't the case, and the
data-handler must override that value.
java.sql.Types
that should
be used to bind null values in prepared-statements.public boolean isCharacterData()
loadValue(java.sql.ResultSet, int)
for character data
columns will always be of type
DataHighBitAnalysis
.
public boolean isNullHandler()
DataHandlerFactory
cannot construct an appropriate
handler for a specific column type. Null handlers are not allowed in
primary key columns, because this will make rows indistinguishable.
public java.lang.Object loadValue(java.sql.ResultSet resultSet, int columnIndex) throws java.sql.SQLException
java.lang.Comparable
and provide reasonable
equals()
, hashCode()
and toString()
implementations.
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 void postProcessBind(java.sql.Connection connection, java.util.List primaryKeyValues, java.lang.Object value) throws java.sql.SQLException
requiresBindPostProcessing()
returns true
to finish writing data to the database for which simple binding isn't
sufficient. This is the case with LOB data, for example.
connection
- The database connection to use.primaryKeyValues
- The primary key values identifying the row that
the specified value has to be written to.value
- The value to write to the database.
java.sql.SQLException
- If a SQL error occurs during binding.public java.lang.String printNonNullValue(java.lang.Object value)
value
- The object value to print, which is guaranteed to be
non-null.
public boolean requiresBindPostProcessing()
postProcessBind(java.sql.Connection, java.util.List, java.lang.Object)
will be called after the initial INSERT or UDPATE
statement that handled the bind step is executed.
public boolean requiresStreamedLoading()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |