类 NativeJdbcExtractorAdapter
- java.lang.Object
- org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractorAdapter
- 所有已实现的接口:
NativeJdbcExtractor
- 直接已知子类:
C3P0NativeJdbcExtractor
,CommonsDbcpNativeJdbcExtractor
,JBossNativeJdbcExtractor
,Jdbc4NativeJdbcExtractor
,SimpleNativeJdbcExtractor
,WebLogicNativeJdbcExtractor
,WebSphereNativeJdbcExtractor
public abstract class NativeJdbcExtractorAdapter extends Object implements NativeJdbcExtractor
Abstract adapter class for theNativeJdbcExtractor
interface, for simplified implementation of basic extractors. Basically returns the passed-in JDBC objects on all methods.getNativeConnection
checks for a ConnectionProxy chain, for example from a TransactionAwareDataSourceProxy, before delegating todoGetNativeConnection
for actual unwrapping. You can override either of the two for a specific connection pool, but the latter is recommended to participate in ConnectionProxy unwrapping.getNativeConnection
also applies a fallback if the first native extraction process failed, that is, returned the same Connection as passed in. It assumes that some additional proxying is going in this case: Hence, it retrieves the underlying native Connection from the DatabaseMetaData viaconHandle.getMetaData().getConnection()
and retries the native extraction process based on that Connection handle. This works, for example, for the Connection proxies exposed by Hibernate 3.1'sSession.connection()
.The
getNativeConnectionFromStatement
method is implemented to simply delegate togetNativeConnection
with the Statement's Connection. This is what most extractor implementations will stick to, unless there's a more efficient version for a specific pool.- 从以下版本开始:
- 1.1
- 作者:
- Juergen Hoeller
- 另请参阅:
getNativeConnection(java.sql.Connection)
,getNativeConnectionFromStatement(java.sql.Statement)
,ConnectionProxy
构造器概要
构造器 构造器 说明 NativeJdbcExtractorAdapter()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected Connection
doGetNativeConnection(Connection con)
Not able to unwrap: return passed-in Connection.CallableStatement
getNativeCallableStatement(CallableStatement cs)
Not able to unwrap: return passed-in CallableStatement.Connection
getNativeConnection(Connection con)
Check for a ConnectionProxy chain, then delegate to doGetNativeConnection.Connection
getNativeConnectionFromStatement(Statement stmt)
Retrieve the Connection via the Statement's Connection.PreparedStatement
getNativePreparedStatement(PreparedStatement ps)
Not able to unwrap: return passed-in PreparedStatement.ResultSet
getNativeResultSet(ResultSet rs)
Not able to unwrap: return passed-in ResultSet.Statement
getNativeStatement(Statement stmt)
Not able to unwrap: return passed-in Statement.boolean
isNativeConnectionNecessaryForNativeCallableStatements()
Returnfalse
by default.boolean
isNativeConnectionNecessaryForNativePreparedStatements()
Returnfalse
by default.boolean
isNativeConnectionNecessaryForNativeStatements()
Returnfalse
by default.
构造器详细资料
NativeJdbcExtractorAdapter
public NativeJdbcExtractorAdapter()
方法详细资料
isNativeConnectionNecessaryForNativeStatements
public boolean isNativeConnectionNecessaryForNativeStatements()
Returnfalse
by default.
isNativeConnectionNecessaryForNativePreparedStatements
public boolean isNativeConnectionNecessaryForNativePreparedStatements()
Returnfalse
by default.
isNativeConnectionNecessaryForNativeCallableStatements
public boolean isNativeConnectionNecessaryForNativeCallableStatements()
Returnfalse
by default.
getNativeConnection
public Connection getNativeConnection(Connection con) throws SQLException
Check for a ConnectionProxy chain, then delegate to doGetNativeConnection.ConnectionProxy is used by Spring's TransactionAwareDataSourceProxy and LazyConnectionDataSourceProxy. The target connection behind it is typically one from a local connection pool, to be unwrapped by the doGetNativeConnection implementation of a concrete subclass.
- 指定者:
getNativeConnection
在接口中NativeJdbcExtractor
- 参数:
con
- the Connection handle, potentially wrapped by a connection pool- 返回:
- the underlying native JDBC Connection, if possible; else, the original Connection
- 抛出:
SQLException
- if thrown by JDBC methods- 另请参阅:
doGetNativeConnection(java.sql.Connection)
,ConnectionProxy
,DataSourceUtils.getTargetConnection(java.sql.Connection)
,TransactionAwareDataSourceProxy
,LazyConnectionDataSourceProxy
doGetNativeConnection
protected Connection doGetNativeConnection(Connection con) throws SQLException
Not able to unwrap: return passed-in Connection.- 抛出:
SQLException
getNativeConnectionFromStatement
public Connection getNativeConnectionFromStatement(Statement stmt) throws SQLException
Retrieve the Connection via the Statement's Connection.- 指定者:
getNativeConnectionFromStatement
在接口中NativeJdbcExtractor
- 参数:
stmt
- the Statement handle, potentially wrapped by a connection pool- 返回:
- the underlying native JDBC Connection, if possible; else, the original Connection
- 抛出:
SQLException
- if thrown by JDBC methods- 另请参阅:
getNativeConnection(java.sql.Connection)
,Statement.getConnection()
getNativeStatement
public Statement getNativeStatement(Statement stmt) throws SQLException
Not able to unwrap: return passed-in Statement.- 指定者:
getNativeStatement
在接口中NativeJdbcExtractor
- 参数:
stmt
- the Statement handle, potentially wrapped by a connection pool- 返回:
- the underlying native JDBC Statement, if possible; else, the original Statement
- 抛出:
SQLException
- if thrown by JDBC methods
getNativePreparedStatement
public PreparedStatement getNativePreparedStatement(PreparedStatement ps) throws SQLException
Not able to unwrap: return passed-in PreparedStatement.- 指定者:
getNativePreparedStatement
在接口中NativeJdbcExtractor
- 参数:
ps
- the PreparedStatement handle, potentially wrapped by a connection pool- 返回:
- the underlying native JDBC PreparedStatement, if possible; else, the original PreparedStatement
- 抛出:
SQLException
- if thrown by JDBC methods
getNativeCallableStatement
public CallableStatement getNativeCallableStatement(CallableStatement cs) throws SQLException
Not able to unwrap: return passed-in CallableStatement.- 指定者:
getNativeCallableStatement
在接口中NativeJdbcExtractor
- 参数:
cs
- the CallableStatement handle, potentially wrapped by a connection pool- 返回:
- the underlying native JDBC CallableStatement, if possible; else, the original CallableStatement
- 抛出:
SQLException
- if thrown by JDBC methods
getNativeResultSet
public ResultSet getNativeResultSet(ResultSet rs) throws SQLException
Not able to unwrap: return passed-in ResultSet.- 指定者:
getNativeResultSet
在接口中NativeJdbcExtractor
- 参数:
rs
- the ResultSet handle, potentially wrapped by a connection pool- 返回:
- the underlying native JDBC ResultSet, if possible; else, the original ResultSet
- 抛出:
SQLException
- if thrown by JDBC methods