|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor
Implementation of the NativeJdbcExtractor interface for the Jakarta Commons DBCP connection pool. Returns the underlying native Connection, Statement, ResultSet etc to application code instead of DBCP's wrapper implementations. The returned JDBC classes can then safely be cast, e.g. to OracleResultSet.
This NativeJdbcExtractor can be set just to allow working with a Commons DBCP DataSource: If a given object is not a Commons DBCP wrapper, it will be returned as-is.
Note: Before Commons DBCP 1.1, DelegatingCallableStatement and DelegatingResultSet have not offered any means to access underlying delegates. Therefore, getNativeCallableStatement and getNativeResultSet will just work with DBCP 1.1. But getNativeResultSet will not be invoked by JdbcTemplate for a wrapped ResultSet anyway, because getNativeStatement/getNativePreparedStatement will already have returned the underlying delegate before.
JdbcTemplate.setNativeJdbcExtractor(org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor)
Constructor Summary | |
CommonsDbcpNativeJdbcExtractor()
|
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. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public CommonsDbcpNativeJdbcExtractor()
Method Detail |
public boolean isNativeConnectionNecessaryForNativeStatements()
NativeJdbcExtractor
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.
isNativeConnectionNecessaryForNativeStatements
in interface NativeJdbcExtractor
public boolean isNativeConnectionNecessaryForNativePreparedStatements()
NativeJdbcExtractor
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.
isNativeConnectionNecessaryForNativePreparedStatements
in interface NativeJdbcExtractor
public boolean isNativeConnectionNecessaryForNativeCallableStatements()
NativeJdbcExtractor
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.
isNativeConnectionNecessaryForNativeCallableStatements
in interface NativeJdbcExtractor
public java.sql.Connection getNativeConnection(java.sql.Connection con)
NativeJdbcExtractor
getNativeConnection
in interface NativeJdbcExtractor
con
- the Connection handle, potentially wrapped by a connection pool
public java.sql.Connection getNativeConnectionFromStatement(java.sql.Statement stmt) throws java.sql.SQLException
NativeJdbcExtractor
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.
getNativeConnectionFromStatement
in interface NativeJdbcExtractor
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)
NativeJdbcExtractor
getNativeStatement
in interface NativeJdbcExtractor
stmt
- the Statement handle, potentially wrapped by a connection pool
public java.sql.PreparedStatement getNativePreparedStatement(java.sql.PreparedStatement ps)
NativeJdbcExtractor
getNativePreparedStatement
in interface NativeJdbcExtractor
ps
- the PreparedStatement handle, potentially wrapped by a connection pool
public java.sql.CallableStatement getNativeCallableStatement(java.sql.CallableStatement cs)
NativeJdbcExtractor
getNativeCallableStatement
in interface NativeJdbcExtractor
cs
- the CallableStatement handle, potentially wrapped by a connection pool
public java.sql.ResultSet getNativeResultSet(java.sql.ResultSet rs) throws java.sql.SQLException
NativeJdbcExtractor
getNativeResultSet
in interface NativeJdbcExtractor
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 |