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 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  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 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.

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, or null in case of SQL NULL
Throws:
SQLException - if thrown by JDBC methods

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.

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, or null in case of SQL NULL
Throws:
SQLException - if thrown by JDBC methods

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.

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, or null in case of SQL NULL
Throws:
SQLException - if thrown by JDBC methods

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.

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, or null in case of SQL NULL
Throws:
SQLException - if thrown by JDBC methods

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.

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:
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.