org.springframework.jdbc.support.lob
Class DefaultLobHandler

java.lang.Object
  extended byorg.springframework.jdbc.support.lob.DefaultLobHandler
All Implemented Interfaces:
LobHandler

public class DefaultLobHandler
extends java.lang.Object
implements LobHandler

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.

Since:
04.12.2003
Author:
Juergen Hoeller
See Also:
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  org.apache.commons.logging.Log logger
           
 
Constructor Summary
DefaultLobHandler()
           
 
Method Summary
 java.io.InputStream getBlobAsBinaryStream(java.sql.ResultSet rs, int columnIndex)
          Retrieve the given column as binary stream from the given ResultSet.
 byte[] getBlobAsBytes(java.sql.ResultSet rs, int columnIndex)
          Retrieve the given column as bytes from the given ResultSet.
 java.io.InputStream getClobAsAsciiStream(java.sql.ResultSet rs, int columnIndex)
          Retrieve the given column as ASCII stream from the given ResultSet.
 java.io.Reader getClobAsCharacterStream(java.sql.ResultSet rs, int columnIndex)
          Retrieve the given column as character stream from the given ResultSet.
 java.lang.String getClobAsString(java.sql.ResultSet rs, int columnIndex)
          Retrieve the given column as String from the given ResultSet.
 LobCreator getLobCreator()
          Create a new LobCreator instance, i.e.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.apache.commons.logging.Log logger
Constructor Detail

DefaultLobHandler

public DefaultLobHandler()
Method Detail

getBlobAsBytes

public byte[] getBlobAsBytes(java.sql.ResultSet rs,
                             int columnIndex)
                      throws java.sql.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.

Specified by:
getBlobAsBytes in interface LobHandler
Parameters:
rs - the ResultSet to retrieve the content from
columnIndex - the column index to use
Returns:
the content as byte array
Throws:
java.sql.SQLException - if thrown by JDBC methods

getBlobAsBinaryStream

public java.io.InputStream getBlobAsBinaryStream(java.sql.ResultSet rs,
                                                 int columnIndex)
                                          throws java.sql.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.

Specified by:
getBlobAsBinaryStream in interface LobHandler
Parameters:
rs - the ResultSet to retrieve the content from
columnIndex - the column index to use
Returns:
the content as binary stream
Throws:
java.sql.SQLException - if thrown by JDBC methods

getClobAsString

public java.lang.String getClobAsString(java.sql.ResultSet rs,
                                        int columnIndex)
                                 throws java.sql.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.

Specified by:
getClobAsString in interface LobHandler
Parameters:
rs - the ResultSet to retrieve the content from
columnIndex - the column index to use
Returns:
the content as String
Throws:
java.sql.SQLException - if thrown by JDBC methods

getClobAsAsciiStream

public java.io.InputStream getClobAsAsciiStream(java.sql.ResultSet rs,
                                                int columnIndex)
                                         throws java.sql.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.

Specified by:
getClobAsAsciiStream in interface LobHandler
Parameters:
rs - the ResultSet to retrieve the content from
columnIndex - the column index to use
Returns:
the content as ASCII stream
Throws:
java.sql.SQLException - if thrown by JDBC methods

getClobAsCharacterStream

public java.io.Reader getClobAsCharacterStream(java.sql.ResultSet rs,
                                               int columnIndex)
                                        throws java.sql.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.

Specified by:
getClobAsCharacterStream in interface LobHandler
Parameters:
rs - the ResultSet to retrieve the content from
columnIndex - the column index to use
Returns:
the content as character stream
Throws:
java.sql.SQLException - if thrown by JDBC methods

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.

Specified by:
getLobCreator in interface LobHandler
Returns:
the new LobCreator instance
See Also:
LobCreator.close()


Copyright (C) 2003-2004 The Spring Framework Project.