LobHandler implementation for Oracle databases. Uses proprietary API
oracle.sql.CLOBinstances, 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
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 as
DefaultLobHandler#setCreateTemporaryLobare available as well, rendering this proprietary OracleLobHandler obsolete.
Also, consider upgrading to a new driver even when accessing an older database.
LobHandler 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
org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractorto 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.