Interface for extracting native JDBC objects from wrapped objects coming from connection pools. This is necessary to allow for casting to native implementations like
OracleConnection
or
OracleResultSet
in application code, for example to create Blobs or to access vendor-specific features.
Note: Setting a custom NativeJdbcExtractor
is just necessary if you intend to cast to database-specific implementations like OracleConnection
or OracleResultSet
. Otherwise, any wrapped JDBC object will be fine, with no need for unwrapping.
Note: To be able to support any pool's strategy of native ResultSet wrapping, it is advisable to get both the native Statement and the native ResultSet via this extractor. Some pools just allow to unwrap the Statement, some just to unwrap the ResultSet - the above strategy will cover both. It is typically not necessary to unwrap the Connection to retrieve a native ResultSet.
When working with a simple connection pool that wraps Connections but not Statements, a {@link SimpleNativeJdbcExtractor} is often sufficient. However,some pools (like Jakarta's Commons DBCP) wrap all JDBC objects that they return: Therefore, you need to use a specific NativeJdbcExtractor
(like {@link CommonsDbcpNativeJdbcExtractor}) with them.
{@link org.springframework.jdbc.core.JdbcTemplate} can properly apply aNativeJdbcExtractor
if specified, unwrapping all JDBC objects that it creates. Note that this is just necessary if you intend to cast to native implementations in your data access code.
{@link org.springframework.jdbc.support.lob.OracleLobHandler}, the Oracle-specific implementation of Spring's {@link org.springframework.jdbc.support.lob.LobHandler} interface, requires aNativeJdbcExtractor
for obtaining the native OracleConnection
. This is also necessary for other Oracle-specific features that you may want to leverage in your applications, such as Oracle InterMedia.
@author Juergen Hoeller
@since 25.08.2003
@see SimpleNativeJdbcExtractor
@see CommonsDbcpNativeJdbcExtractor
@see org.springframework.jdbc.core.JdbcTemplate#setNativeJdbcExtractor
@see org.springframework.jdbc.support.lob.OracleLobHandler#setNativeJdbcExtractor