|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Interface for extracting native JDBC objects from wrapped objects coming from connection pools. This is necessary to be able to case to native implementations like OracleConnection or OracleResultSet in application code, for example to create Blobs or access other vendor-specific features.
Note: Setting a custom NativeJdbcExtractor is just necessary if you want to cast to database-specific implementations, like OracleConnection/OracleResultSet. Else, any wrapped JDBC object will be fine.
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 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 CommonsDbcpNativeJdbcExtractor) with them.
JdbcTemplate can properly apply a NativeJdbcExtractor if specified, correctly unwrapping all JDBC objects that it creates. Note that this is just necessary if you want to cast to native implementations in your data access code.
The Oracle-specific implementation of Spring's LobHandler interface needs a NativeJdbcExtractor to be able to work on the native OracleConnection. This is also necessary for other Oracle-specific features that you may want to leverage in your applications, like InterMedia.
SimpleNativeJdbcExtractor
,
CommonsDbcpNativeJdbcExtractor
,
JdbcTemplate.setNativeJdbcExtractor(org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor)
,
OracleLobHandler.setNativeJdbcExtractor(org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor)
Method Summary | |
java.sql.CallableStatement |
getNativeCallableStatement(java.sql.CallableStatement cs)
Retrieve the underlying native JDBC CallableStatement for the given statement. |
java.sql.Connection |
getNativeConnection(java.sql.Connection con)
Retrieve the underlying native JDBC Connection for the given Connection. |
java.sql.Connection |
getNativeConnectionFromStatement(java.sql.Statement stmt)
Retrieve the underlying native JDBC Connection for the given Statement. |
java.sql.PreparedStatement |
getNativePreparedStatement(java.sql.PreparedStatement ps)
Retrieve the underlying native JDBC PreparedStatement for the given statement. |
java.sql.ResultSet |
getNativeResultSet(java.sql.ResultSet rs)
Retrieve the underlying native JDBC ResultSet for the given statement. |
java.sql.Statement |
getNativeStatement(java.sql.Statement stmt)
Retrieve the underlying native JDBC Statement for the given Statement. |
boolean |
isNativeConnectionNecessaryForNativeCallableStatements()
Return whether it is necessary to work on the native Connection to receive native CallableStatements. |
boolean |
isNativeConnectionNecessaryForNativePreparedStatements()
Return whether it is necessary to work on the native Connection to receive native PreparedStatements. |
boolean |
isNativeConnectionNecessaryForNativeStatements()
Return whether it is necessary to work on the native Connection to receive native Statements. |
Method Detail |
public boolean isNativeConnectionNecessaryForNativeStatements()
This should be true if the connection pool does not allow to extract the native JDBC objects from its Statement wrapper but supports a way to retrieve the native JDBC Connection. This way, applications can still receive native Statements and ResultSet via working on the native JDBC Connection.
public boolean isNativeConnectionNecessaryForNativePreparedStatements()
This should be true if the connection pool does not allow to extract the native JDBC objects from its PreparedStatement wrappers but supports a way to retrieve the native JDBC Connection. This way, applications can still receive native Statements and ResultSet via working on the native JDBC Connection.
public boolean isNativeConnectionNecessaryForNativeCallableStatements()
This should be true if the connection pool does not allow to extract the native JDBC objects from its CallableStatement wrappers but supports a way to retrieve the native JDBC Connection. This way, applications can still receive native Statements and ResultSet via working on the native JDBC Connection.
public java.sql.Connection getNativeConnection(java.sql.Connection con) throws java.sql.SQLException
con
- the Connection handle, potentially wrapped by a connection pool
java.sql.SQLException
- if thrown by JDBC methodspublic java.sql.Connection getNativeConnectionFromStatement(java.sql.Statement stmt) throws java.sql.SQLException
Having this extra method allows for more efficient unwrapping if data access code already has a Statement. Statement.getConnection() often returns the native JDBC Connection even if the Statement itself is wrapped by a pool.
stmt
- the Statement handle, potentially wrapped by a connection pool
java.sql.SQLException
- if thrown by JDBC methodspublic java.sql.Statement getNativeStatement(java.sql.Statement stmt) throws java.sql.SQLException
stmt
- the Statement handle, potentially wrapped by a connection pool
java.sql.SQLException
- if thrown by JDBC methodspublic java.sql.PreparedStatement getNativePreparedStatement(java.sql.PreparedStatement ps) throws java.sql.SQLException
ps
- the PreparedStatement handle, potentially wrapped by a connection pool
java.sql.SQLException
- if thrown by JDBC methodspublic java.sql.CallableStatement getNativeCallableStatement(java.sql.CallableStatement cs) throws java.sql.SQLException
cs
- the CallableStatement handle, potentially wrapped by a connection pool
java.sql.SQLException
- if thrown by JDBC methodspublic java.sql.ResultSet getNativeResultSet(java.sql.ResultSet rs) throws java.sql.SQLException
rs
- the ResultSet handle, potentially wrapped by a connection pool
java.sql.SQLException
- if thrown by JDBC methods
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |