|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface LobHandler
Abstraction for handling large binary fields and large text fields in specific databases, no matter if represented as simple types or Large OBjects. Its main purpose is to isolate Oracle's peculiar handling of LOBs in OracleLobHandler; most other databases should work with DefaultLobHandler.
Provides accessor methods for BLOBs and CLOBs, and acts as factory for LobCreator instances, to be used as sessions for creating BLOBs or CLOBs. LobCreators are typically instantiated for each statement execution or for each transaction. They are not thread-safe because they might track allocated database resources to be able to free them after execution.
Most databases/drivers should be able to work with DefaultLobHandler,
which simply delegates to JDBC's direct accessor methods, avoiding
java.sql.Blob
and java.sql.Clob
completely.
Unfortunately, Oracle 9i just accepts Blob/Clob instances created via its own proprietary BLOB/CLOB API, and additionally doesn't accept large streams for PreparedStatement's corresponding setter methods. Therefore, you need to use OracleLobHandler there, which uses Oracle's BLOB/CLOB API for both all access. The Oracle 10g JDBC driver should work with DefaultLobHandler too.
Of course, you need to declare different field types for each database. In Oracle, any binary content needs to go into a BLOB, and all character content beyond 4000 bytes needs to go into a CLOB. In MySQL, there is no notion of a CLOB type but rather a LONGTEXT type that behaves like a VARCHAR. For complete portability, just use a LobHandler for fields that might typically require LOBs on some database because of their size (take Oracle's numbers as a guideline).
DefaultLobHandler
,
OracleLobHandler
,
ResultSet.getBlob(int)
,
ResultSet.getClob(int)
,
ResultSet.getBytes(int)
,
ResultSet.getBinaryStream(int)
,
ResultSet.getString(int)
,
ResultSet.getAsciiStream(int)
,
ResultSet.getCharacterStream(int)
Method Summary | |
---|---|
InputStream |
getBlobAsBinaryStream(ResultSet rs,
int columnIndex)
Retrieve the given column as binary stream from the given ResultSet. |
InputStream |
getBlobAsBinaryStream(ResultSet rs,
String columnName)
Retrieve the given column as binary stream from the given ResultSet. |
byte[] |
getBlobAsBytes(ResultSet rs,
int columnIndex)
Retrieve the given column as bytes from the given ResultSet. |
byte[] |
getBlobAsBytes(ResultSet rs,
String columnName)
Retrieve the given column as bytes from the given ResultSet. |
InputStream |
getClobAsAsciiStream(ResultSet rs,
int columnIndex)
Retrieve the given column as ASCII stream from the given ResultSet. |
InputStream |
getClobAsAsciiStream(ResultSet rs,
String columnName)
Retrieve the given column as ASCII stream from the given ResultSet. |
Reader |
getClobAsCharacterStream(ResultSet rs,
int columnIndex)
Retrieve the given column as character stream from the given ResultSet. |
Reader |
getClobAsCharacterStream(ResultSet rs,
String columnName)
Retrieve the given column as character stream from the given ResultSet. |
String |
getClobAsString(ResultSet rs,
int columnIndex)
Retrieve the given column as String from the given ResultSet. |
String |
getClobAsString(ResultSet rs,
String columnName)
Retrieve the given column as String from the given ResultSet. |
LobCreator |
getLobCreator()
Create a new LobCreator instance, i.e. a session for creating BLOBs and CLOBs. |
Method Detail |
---|
byte[] getBlobAsBytes(ResultSet rs, String columnName) throws SQLException
ResultSet.getBytes
or work with
ResultSet.getBlob
, depending on the database and driver.
rs
- the ResultSet to retrieve the content fromcolumnName
- the column name to use
null
in case of SQL NULL
SQLException
- if thrown by JDBC methodsResultSet.getBytes(int)
byte[] getBlobAsBytes(ResultSet rs, int columnIndex) throws SQLException
ResultSet.getBytes
or work with
ResultSet.getBlob
, depending on the database and driver.
rs
- the ResultSet to retrieve the content fromcolumnIndex
- the column index to use
null
in case of SQL NULL
SQLException
- if thrown by JDBC methodsResultSet.getBytes(int)
InputStream getBlobAsBinaryStream(ResultSet rs, String columnName) throws SQLException
ResultSet.getBinaryStream
or work with
ResultSet.getBlob
, depending on the database and driver.
rs
- the ResultSet to retrieve the content fromcolumnName
- the column name to use
null
in case of SQL NULL
SQLException
- if thrown by JDBC methodsResultSet.getBinaryStream(int)
InputStream getBlobAsBinaryStream(ResultSet rs, int columnIndex) throws SQLException
ResultSet.getBinaryStream
or work with
ResultSet.getBlob
, depending on the database and driver.
rs
- the ResultSet to retrieve the content fromcolumnIndex
- the column index to use
null
in case of SQL NULL
SQLException
- if thrown by JDBC methodsResultSet.getBinaryStream(int)
String getClobAsString(ResultSet rs, String columnName) throws SQLException
ResultSet.getString
or work with
ResultSet.getClob
, depending on the database and driver.
rs
- the ResultSet to retrieve the content fromcolumnName
- the column name to use
null
in case of SQL NULL
SQLException
- if thrown by JDBC methodsResultSet.getString(int)
String getClobAsString(ResultSet rs, int columnIndex) throws SQLException
ResultSet.getString
or work with
ResultSet.getClob
, depending on the database and driver.
rs
- the ResultSet to retrieve the content fromcolumnIndex
- the column index to use
null
in case of SQL NULL
SQLException
- if thrown by JDBC methodsResultSet.getString(int)
InputStream getClobAsAsciiStream(ResultSet rs, String columnName) throws SQLException
ResultSet.getAsciiStream
or work with
ResultSet.getClob
, depending on the database and driver.
rs
- the ResultSet to retrieve the content fromcolumnName
- the column name to use
null
in case of SQL NULL
SQLException
- if thrown by JDBC methodsResultSet.getAsciiStream(int)
InputStream getClobAsAsciiStream(ResultSet rs, int columnIndex) throws SQLException
ResultSet.getAsciiStream
or work with
ResultSet.getClob
, depending on the database and driver.
rs
- the ResultSet to retrieve the content fromcolumnIndex
- the column index to use
null
in case of SQL NULL
SQLException
- if thrown by JDBC methodsResultSet.getAsciiStream(int)
Reader getClobAsCharacterStream(ResultSet rs, String columnName) throws SQLException
ResultSet.getCharacterStream
or work with
ResultSet.getClob
, depending on the database and driver.
rs
- the ResultSet to retrieve the content fromcolumnName
- the column name to use
SQLException
- if thrown by JDBC methodsResultSet.getCharacterStream(int)
Reader getClobAsCharacterStream(ResultSet rs, int columnIndex) throws SQLException
ResultSet.getCharacterStream
or work with
ResultSet.getClob
, depending on the database and driver.
rs
- the ResultSet to retrieve the content fromcolumnIndex
- the column index to use
SQLException
- if thrown by JDBC methodsResultSet.getCharacterStream(int)
LobCreator getLobCreator()
LobCreator.close()
|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |