public class

DefaultLobHandler

extends AbstractLobHandler
java.lang.Object
   ↳ org.springframework.jdbc.support.lob.AbstractLobHandler
     ↳ org.springframework.jdbc.support.lob.DefaultLobHandler

Class Overview

Default implementation of the LobHandler interface. Invokes the direct accessor methods that java.sql.ResultSet and java.sql.PreparedStatement offer.

This LobHandler should work for any JDBC driver that is JDBC compliant in terms of the spec's suggestions regarding simple BLOB and CLOB handling. This does not apply to Oracle 9i, and only to a limited degree to Oracle 10g! As a consequence, use OracleLobHandler for accessing Oracle BLOBs/CLOBs.

Some JDBC drivers require values with a BLOB/CLOB target column to be explicitly set through the JDBC setBlob / setClob API: for example, PostgreSQL's driver. Switch the "wrapAsLob" property to "true" when operating against such a driver.

On JDBC 4.0, this LobHandler also supports streaming the BLOB/CLOB content via the setBlob / setClob variants that take a stream argument directly. Consider switching the "streamAsLob" property to "true" when operating against a fully compliant JDBC 4.0 driver.

See the LobHandler javadoc for a summary of recommendations.

Summary

Nested Classes
class DefaultLobHandler.DefaultLobCreator Default LobCreator implementation as inner class. 
Fields
protected final Log logger
Public Constructors
DefaultLobHandler()
Public Methods
InputStream getBlobAsBinaryStream(ResultSet rs, int columnIndex)
byte[] getBlobAsBytes(ResultSet rs, int columnIndex)
InputStream getClobAsAsciiStream(ResultSet rs, int columnIndex)
Reader getClobAsCharacterStream(ResultSet rs, int columnIndex)
String getClobAsString(ResultSet rs, int columnIndex)
LobCreator getLobCreator()
void setStreamAsLob(boolean streamAsLob)
Specify whether to submit a binary stream / character stream to the JDBC driver as explicit LOB content, using the JDBC 4.0 setBlob / setClob method with a stream argument.
void setWrapAsLob(boolean wrapAsLob)
Specify whether to submit a byte array / String to the JDBC driver wrapped in a JDBC Blob / Clob object, using the JDBC setBlob / setClob method with a Blob / Clob argument.
[Expand]
Inherited Methods
From class org.springframework.jdbc.support.lob.AbstractLobHandler
From class java.lang.Object
From interface org.springframework.jdbc.support.lob.LobHandler

Fields

protected final Log logger

Public Constructors

public DefaultLobHandler ()

Public Methods

public InputStream getBlobAsBinaryStream (ResultSet rs, int columnIndex)

Throws
SQLException

public byte[] getBlobAsBytes (ResultSet rs, int columnIndex)

Throws
SQLException

public InputStream getClobAsAsciiStream (ResultSet rs, int columnIndex)

Throws
SQLException

public Reader getClobAsCharacterStream (ResultSet rs, int columnIndex)

Throws
SQLException

public String getClobAsString (ResultSet rs, int columnIndex)

Throws
SQLException

public LobCreator getLobCreator ()

public void setStreamAsLob (boolean streamAsLob)

Specify whether to submit a binary stream / character stream to the JDBC driver as explicit LOB content, using the JDBC 4.0 setBlob / setClob method with a stream argument.

Default is "false", using the common JDBC 2.0 setBinaryStream / setCharacterStream method for setting the content. Switch this to "true" for explicit JDBC 4.0 usage, provided that your JDBC driver actually supports those JDBC 4.0 operations (e.g. Derby's).

This setting affects stream arguments as well as byte array / String arguments, requiring JDBC 4.0 support. For supporting LOB content against JDBC 3.0, check out the "wrapAsLob" setting.

public void setWrapAsLob (boolean wrapAsLob)

Specify whether to submit a byte array / String to the JDBC driver wrapped in a JDBC Blob / Clob object, using the JDBC setBlob / setClob method with a Blob / Clob argument.

Default is "false", using the common JDBC 2.0 setBinaryStream / setCharacterStream method for setting the content. Switch this to "true" for explicit Blob / Clob wrapping against JDBC drivers that are known to require such wrapping (e.g. PostgreSQL's).

This setting affects byte array / String arguments as well as stream arguments, unless "streamAsLob" overrides this handling to use JDBC 4.0's new explicit streaming support (if available).