类 OracleLobHandler
- java.lang.Object
- org.springframework.jdbc.support.lob.AbstractLobHandler
- org.springframework.jdbc.support.lob.OracleLobHandler
- 所有已实现的接口:
LobHandler
@Deprecated public class OracleLobHandler extends AbstractLobHandler
已过时。in favor ofDefaultLobHandler
for the Oracle 10g driver and higher. Consider using the 10g/11g driver even against an Oracle 9i database!DefaultLobHandler.setCreateTemporaryLob(boolean)
is the direct equivalent of this OracleLobHandler's implementation strategy, just using standard JDBC 4.0 API. That said, in most cases, regular DefaultLobHandler setup will work fine as well.LobHandler
implementation for Oracle databases. Uses proprietary API to createoracle.sql.BLOB
andoracle.sql.CLOB
instances, as necessary when working with Oracle's JDBC driver. Note that this LobHandler requires Oracle JDBC driver 9i or higher!While most databases are able to work with
DefaultLobHandler
, Oracle 9i (or more specifically, the Oracle 9i JDBC driver) 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 a strategy like this LobHandler implementation, or upgrade to the Oracle 10g/11g driver (which still supports access to Oracle 9i databases).NOTE: As of Oracle 10.2,
DefaultLobHandler
should work equally well out of the box. On Oracle 11g, JDBC 4.0 based options such asDefaultLobHandler.setStreamAsLob(boolean)
andDefaultLobHandler.setCreateTemporaryLob(boolean)
are available as well, rendering this proprietary OracleLobHandler obsolete. Also, consider upgrading to a new driver even when accessing an older database. See theLobHandler
interface javadoc for a summary of recommendations.Needs to work on a native JDBC Connection, to be able to cast it to
oracle.jdbc.OracleConnection
. If you pass in Connections from a connection pool (the usual case in a Java EE environment), you need to set an appropriateNativeJdbcExtractor
to allow for automatic retrieval of the underlying native JDBC Connection. LobHandler and NativeJdbcExtractor are separate concerns, therefore they are represented by separate strategy interfaces.Coded via reflection to avoid dependencies on Oracle classes. Even reads in Oracle constants via reflection because of different Oracle drivers (classes12, ojdbc14, ojdbc5, ojdbc6) having different constant values! As this LobHandler initializes Oracle classes on instantiation, do not define this as eager-initializing singleton if you do not want to depend on the Oracle JAR being in the class path: use "lazy-init=true" to avoid this issue.
- 从以下版本开始:
- 04.12.2003
- 作者:
- Juergen Hoeller, Thomas Risberg
- 另请参阅:
DefaultLobHandler
,setNativeJdbcExtractor(org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor)
嵌套类概要
嵌套类 修饰符和类型 类 说明 protected static interface
OracleLobHandler.LobCallback
已过时。Internal callback interface for use with createLob.protected class
OracleLobHandler.OracleLobCreator
已过时。LobCreator implementation for Oracle databases.
构造器概要
构造器 构造器 说明 OracleLobHandler()
已过时。
方法概要
所有方法 实例方法 具体方法 已过时的方法 修饰符和类型 方法 说明 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 newLobCreator
instance, i.e. a session for creating BLOBs and CLOBs.protected void
initializeResourcesBeforeRead(Connection con, Object lob)
已过时。Initialize any LOB resources before a read is done.protected void
initOracleDriverClasses(Connection con)
已过时。Retrieve theoracle.sql.BLOB
andoracle.sql.CLOB
classes via reflection, and initialize the values for the DURATION_SESSION, MODE_READWRITE and MODE_READONLY constants defined there.protected void
releaseResourcesAfterRead(Connection con, Object lob)
已过时。Release any LOB resources after read is complete.void
setCache(boolean cache)
已过时。Set whether to cache the temporary LOB in the buffer cache.void
setNativeJdbcExtractor(NativeJdbcExtractor nativeJdbcExtractor)
已过时。Set an appropriate NativeJdbcExtractor to be able to retrieve the underlying nativeoracle.jdbc.OracleConnection
.void
setReleaseResourcesAfterRead(boolean releaseResources)
已过时。Set whether to aggressively release any resources used by the LOB.从类继承的方法 org.springframework.jdbc.support.lob.AbstractLobHandler
getBlobAsBinaryStream, getBlobAsBytes, getClobAsAsciiStream, getClobAsCharacterStream, getClobAsString
构造器详细资料
OracleLobHandler
public OracleLobHandler()
已过时。
方法详细资料
setNativeJdbcExtractor
public void setNativeJdbcExtractor(NativeJdbcExtractor nativeJdbcExtractor)
已过时。Set an appropriate NativeJdbcExtractor to be able to retrieve the underlying nativeoracle.jdbc.OracleConnection
. This is necessary for DataSource-based connection pools, as those need to return wrapped JDBC Connection handles that cannot be cast to a native Connection implementation.Effectively, this LobHandler just invokes a single NativeJdbcExtractor method, namely
getNativeConnectionFromStatement
with a PreparedStatement argument (falling back to aPreparedStatement.getConnection()
call if no extractor is set).A common choice is
SimpleNativeJdbcExtractor
, whose Connection unwrapping (which is what OracleLobHandler needs) will work with many connection pools. SeeSimpleNativeJdbcExtractor
and oracle.jdbc.OracleConnection javadoc for details.
setCache
public void setCache(boolean cache)
已过时。Set whether to cache the temporary LOB in the buffer cache. This value will be passed into BLOB/CLOB.createTemporary.Default is
true
.See Also:
setReleaseResourcesAfterRead
public void setReleaseResourcesAfterRead(boolean releaseResources)
已过时。Set whether to aggressively release any resources used by the LOB. If set totrue
then you can only read the LOB values once. Any subsequent reads will fail since the resources have been closed.Setting this property to
true
can be useful when your queries generates large temporary LOBs that occupy space in the TEMPORARY tablespace or when you want to free up any memory allocated by the driver for the LOB reading.Default is
false
.See Also:
initOracleDriverClasses
protected void initOracleDriverClasses(Connection con)
已过时。Retrieve theoracle.sql.BLOB
andoracle.sql.CLOB
classes via reflection, and initialize the values for the DURATION_SESSION, MODE_READWRITE and MODE_READONLY constants defined there.See Also:
- 参数:
con
- the Oracle Connection, for using the exact same class loader that the Oracle driver was loaded with
getBlobAsBytes
public byte[] getBlobAsBytes(ResultSet rs, int columnIndex) throws SQLException
已过时。从接口复制的说明:LobHandler
Retrieve the given column as bytes from the given ResultSet. Might simply invokeResultSet.getBytes
or work withResultSet.getBlob
, depending on the database and driver.- 参数:
rs
- the ResultSet to retrieve the content fromcolumnIndex
- the column index to use- 返回:
- the content as byte array, or
null
in case of SQL NULL - 抛出:
SQLException
- if thrown by JDBC methods- 另请参阅:
ResultSet.getBytes(int)
getBlobAsBinaryStream
public InputStream getBlobAsBinaryStream(ResultSet rs, int columnIndex) throws SQLException
已过时。从接口复制的说明:LobHandler
Retrieve the given column as binary stream from the given ResultSet. Might simply invokeResultSet.getBinaryStream
or work withResultSet.getBlob
, depending on the database and driver.- 参数:
rs
- the ResultSet to retrieve the content fromcolumnIndex
- the column index to use- 返回:
- the content as binary stream, or
null
in case of SQL NULL - 抛出:
SQLException
- if thrown by JDBC methods- 另请参阅:
ResultSet.getBinaryStream(int)
getClobAsString
public String getClobAsString(ResultSet rs, int columnIndex) throws SQLException
已过时。从接口复制的说明:LobHandler
Retrieve the given column as String from the given ResultSet. Might simply invokeResultSet.getString
or work withResultSet.getClob
, depending on the database and driver.- 参数:
rs
- the ResultSet to retrieve the content fromcolumnIndex
- the column index to use- 返回:
- the content as String, or
null
in case of SQL NULL - 抛出:
SQLException
- if thrown by JDBC methods- 另请参阅:
ResultSet.getString(int)
getClobAsAsciiStream
public InputStream getClobAsAsciiStream(ResultSet rs, int columnIndex) throws SQLException
已过时。从接口复制的说明:LobHandler
Retrieve the given column as ASCII stream from the given ResultSet. Might simply invokeResultSet.getAsciiStream
or work withResultSet.getClob
, depending on the database and driver.- 参数:
rs
- the ResultSet to retrieve the content fromcolumnIndex
- the column index to use- 返回:
- the content as ASCII stream, or
null
in case of SQL NULL - 抛出:
SQLException
- if thrown by JDBC methods- 另请参阅:
ResultSet.getAsciiStream(int)
getClobAsCharacterStream
public Reader getClobAsCharacterStream(ResultSet rs, int columnIndex) throws SQLException
已过时。从接口复制的说明:LobHandler
Retrieve the given column as character stream from the given ResultSet. Might simply invokeResultSet.getCharacterStream
or work withResultSet.getClob
, depending on the database and driver.- 参数:
rs
- the ResultSet to retrieve the content fromcolumnIndex
- the column index to use- 返回:
- the content as character stream
- 抛出:
SQLException
- if thrown by JDBC methods- 另请参阅:
ResultSet.getCharacterStream(int)
getLobCreator
public LobCreator getLobCreator()
已过时。从接口复制的说明:LobHandler
Create a newLobCreator
instance, i.e. a session for creating BLOBs and CLOBs. Needs to be closed after the created LOBs are not needed anymore - typically after statement execution or transaction completion.- 返回:
- the new LobCreator instance
- 另请参阅:
LobCreator.close()
initializeResourcesBeforeRead
protected void initializeResourcesBeforeRead(Connection con, Object lob)
已过时。Initialize any LOB resources before a read is done.This implementation calls
BLOB.open(BLOB.MODE_READONLY)
orCLOB.open(CLOB.MODE_READONLY)
on any non-temporary LOBs ifreleaseResourcesAfterRead
property is set totrue
.This method can be overridden by sublcasses if different behavior is desired.
- 参数:
con
- the connection to be usde for initilizationlob
- the LOB to initialize
releaseResourcesAfterRead
protected void releaseResourcesAfterRead(Connection con, Object lob)
已过时。Release any LOB resources after read is complete.If
releaseResourcesAfterRead
property is set totrue
then this implementation callsBLOB.close()
orCLOB.close()
on any non-temporary LOBs that are open orBLOB.freeTemporary()
orCLOB.freeTemporary()
on any temporary LOBs.This method can be overridden by sublcasses if different behavior is desired.
- 参数:
con
- the connection to be usde for initilizationlob
- the LOB to initialize