org.springframework.jdbc.support.lob
Class DefaultLobHandler

java.lang.Object
  extended by org.springframework.jdbc.support.lob.AbstractLobHandler
      extended by org.springframework.jdbc.support.lob.DefaultLobHandler
All Implemented Interfaces:
LobHandler

public class DefaultLobHandler
extends AbstractLobHandler

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.

Since:
04.12.2003
Author:
Juergen Hoeller
See Also:
OracleLobHandler, ResultSet.getBytes(int), ResultSet.getBinaryStream(int), ResultSet.getString(int), ResultSet.getAsciiStream(int), ResultSet.getCharacterStream(int), PreparedStatement.setBytes(int, byte[]), PreparedStatement.setBinaryStream(int, java.io.InputStream, int), PreparedStatement.setString(int, java.lang.String), PreparedStatement.setAsciiStream(int, java.io.InputStream, int), PreparedStatement.setCharacterStream(int, java.io.Reader, int)

Nested Class Summary
protected  class DefaultLobHandler.DefaultLobCreator
           
 
Field Summary
protected  Log logger
           
 
Constructor Summary
DefaultLobHandler()
           
 
Method Summary
 InputStream getBlobAsBinaryStream(ResultSet rs, int columnIndex)
          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.
 InputStream getClobAsAsciiStream(ResultSet rs, int columnIndex)
          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.
 String getClobAsString(ResultSet rs, int columnIndex)
          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.
 
Methods inherited from class org.springframework.jdbc.support.lob.AbstractLobHandler
getBlobAsBinaryStream, getBlobAsBytes, getClobAsAsciiStream, getClobAsCharacterStream, getClobAsString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final Log logger
Constructor Detail

DefaultLobHandler

public DefaultLobHandler()
Method Detail

getBlobAsBytes

public byte[] getBlobAsBytes(ResultSet rs,
                             int columnIndex)
                      throws SQLException
Description copied from interface: LobHandler
Retrieve the given column as bytes from the given ResultSet. Might simply invoke ResultSet.getBytes or work with ResultSet.getBlob, depending on the database and driver.

Parameters:
rs - the ResultSet to retrieve the content from
columnIndex - the column index to use
Returns:
the content as byte array, or null in case of SQL NULL
Throws:
SQLException - if thrown by JDBC methods
See Also:
ResultSet.getBytes(int)

getBlobAsBinaryStream

public InputStream getBlobAsBinaryStream(ResultSet rs,
                                         int columnIndex)
                                  throws SQLException
Description copied from interface: LobHandler
Retrieve the given column as binary stream from the given ResultSet. Might simply invoke ResultSet.getBinaryStream or work with ResultSet.getBlob, depending on the database and driver.

Parameters:
rs - the ResultSet to retrieve the content from
columnIndex - the column index to use
Returns:
the content as binary stream, or null in case of SQL NULL
Throws:
SQLException - if thrown by JDBC methods
See Also:
ResultSet.getBinaryStream(int)

getClobAsString

public String getClobAsString(ResultSet rs,
                              int columnIndex)
                       throws SQLException
Description copied from interface: LobHandler
Retrieve the given column as String from the given ResultSet. Might simply invoke ResultSet.getString or work with ResultSet.getClob, depending on the database and driver.

Parameters:
rs - the ResultSet to retrieve the content from
columnIndex - the column index to use
Returns:
the content as String, or null in case of SQL NULL
Throws:
SQLException - if thrown by JDBC methods
See Also:
ResultSet.getString(int)

getClobAsAsciiStream

public InputStream getClobAsAsciiStream(ResultSet rs,
                                        int columnIndex)
                                 throws SQLException
Description copied from interface: LobHandler
Retrieve the given column as ASCII stream from the given ResultSet. Might simply invoke ResultSet.getAsciiStream or work with ResultSet.getClob, depending on the database and driver.

Parameters:
rs - the ResultSet to retrieve the content from
columnIndex - the column index to use
Returns:
the content as ASCII stream, or null in case of SQL NULL
Throws:
SQLException - if thrown by JDBC methods
See Also:
ResultSet.getAsciiStream(int)

getClobAsCharacterStream

public Reader getClobAsCharacterStream(ResultSet rs,
                                       int columnIndex)
                                throws SQLException
Description copied from interface: LobHandler
Retrieve the given column as character stream from the given ResultSet. Might simply invoke ResultSet.getCharacterStream or work with ResultSet.getClob, depending on the database and driver.

Parameters:
rs - the ResultSet to retrieve the content from
columnIndex - the column index to use
Returns:
the content as character stream
Throws:
SQLException - if thrown by JDBC methods
See Also:
ResultSet.getCharacterStream(int)

getLobCreator

public LobCreator getLobCreator()
Description copied from interface: LobHandler
Create a new LobCreator instance, i.e. a session for creating BLOBs and CLOBs. Needs to be closed after the created LOBs are not needed anymore, i.e. after statement execution or transaction completion.

Returns:
the new LobCreator instance
See Also:
LobCreator.close()


Copyright (c) 2002-2007 The Spring Framework Project.