类 SimpleNativeJdbcExtractor
- java.lang.Object
- org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractorAdapter
- org.springframework.jdbc.support.nativejdbc.SimpleNativeJdbcExtractor
- 所有已实现的接口:
NativeJdbcExtractor
public class SimpleNativeJdbcExtractor extends NativeJdbcExtractorAdapter
A simple implementation of theNativeJdbcExtractor
interface. Assumes a pool that wraps Connection handles but not DatabaseMetaData: In this case, the underlying native Connection can be retrieved by simply callingconHandle.getMetaData().getConnection()
. All other JDBC objects will be returned as passed in.This extractor should work with any pool that does not wrap DatabaseMetaData, and will also work with any plain JDBC driver. Note that a pool can still wrap Statements, PreparedStatements, etc: The only requirement of this extractor is that
java.sql.DatabaseMetaData
does not get wrapped, returning the native Connection of the JDBC driver onmetaData.getConnection()
.Customize this extractor by setting the "nativeConnectionNecessaryForXxx" flags accordingly: If Statements, PreparedStatements, and/or CallableStatements are wrapped by your pool, set the corresponding "nativeConnectionNecessaryForXxx" flags to "true". If none of the statement types is wrapped - or you solely need Connection unwrapping in the first place -, the defaults are fine.
SimpleNativeJdbcExtractor is a common choice for use with OracleLobHandler, which just needs Connection unwrapping via the
NativeJdbcExtractorAdapter.getNativeConnectionFromStatement(java.sql.Statement)
method. This usage will work with almost any connection pool.For full usage with JdbcTemplate, i.e. to also provide Statement unwrapping:
- Use a default SimpleNativeJdbcExtractor for Resin and SJSAS (no JDBC Statement objects are wrapped, therefore no special unwrapping is necessary).
- Use a SimpleNativeJdbcExtractor with all "nativeConnectionNecessaryForXxx" flags set to "true" for C3P0 (all JDBC Statement objects are wrapped, but none of the wrappers allow for unwrapping).
- Use a CommonsDbcpNativeJdbcExtractor for Apache Commons DBCP or a JBossNativeJdbcExtractor for JBoss (all JDBC Statement objects are wrapped, but all of them can be extracted by casting to implementation classes).
- 从以下版本开始:
- 05.12.2003
- 作者:
- Juergen Hoeller
- 另请参阅:
setNativeConnectionNecessaryForNativeStatements(boolean)
,setNativeConnectionNecessaryForNativePreparedStatements(boolean)
,setNativeConnectionNecessaryForNativeCallableStatements(boolean)
,Jdbc4NativeJdbcExtractor
,JdbcTemplate.setNativeJdbcExtractor(org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor)
,OracleLobHandler.setNativeJdbcExtractor(org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor)
构造器概要
构造器 构造器 说明 SimpleNativeJdbcExtractor()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 boolean
isNativeConnectionNecessaryForNativeCallableStatements()
Returnfalse
by default.boolean
isNativeConnectionNecessaryForNativePreparedStatements()
Returnfalse
by default.boolean
isNativeConnectionNecessaryForNativeStatements()
Returnfalse
by default.void
setNativeConnectionNecessaryForNativeCallableStatements(boolean nativeConnectionNecessary)
Set whether it is necessary to work on the native Connection to receive native CallableStatements.void
setNativeConnectionNecessaryForNativePreparedStatements(boolean nativeConnectionNecessary)
Set whether it is necessary to work on the native Connection to receive native PreparedStatements.void
setNativeConnectionNecessaryForNativeStatements(boolean nativeConnectionNecessaryForNativeStatements)
Set whether it is necessary to work on the native Connection to receive native Statements.从类继承的方法 org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractorAdapter
doGetNativeConnection, getNativeCallableStatement, getNativeConnection, getNativeConnectionFromStatement, getNativePreparedStatement, getNativeResultSet, getNativeStatement
构造器详细资料
SimpleNativeJdbcExtractor
public SimpleNativeJdbcExtractor()
方法详细资料
setNativeConnectionNecessaryForNativeStatements
public void setNativeConnectionNecessaryForNativeStatements(boolean nativeConnectionNecessaryForNativeStatements)
Set whether it is necessary to work on the native Connection to receive native Statements. Default is "false". If true, the Connection will be unwrapped first to create a Statement.This makes sense if you need to work with native Statements from a pool that does not allow to extract the native JDBC objects from its wrappers but returns the native Connection on DatabaseMetaData.getConnection.
The standard SimpleNativeJdbcExtractor is unable to unwrap statements, so set this to true if your connection pool wraps Statements.
isNativeConnectionNecessaryForNativeStatements
public boolean isNativeConnectionNecessaryForNativeStatements()
从类复制的说明:NativeJdbcExtractorAdapter
Returnfalse
by default.
setNativeConnectionNecessaryForNativePreparedStatements
public void setNativeConnectionNecessaryForNativePreparedStatements(boolean nativeConnectionNecessary)
Set whether it is necessary to work on the native Connection to receive native PreparedStatements. Default is "false". If true, the Connection will be unwrapped first to create a PreparedStatement.This makes sense if you need to work with native PreparedStatements from a pool that does not allow to extract the native JDBC objects from its wrappers but returns the native Connection on Statement.getConnection.
The standard SimpleNativeJdbcExtractor is unable to unwrap statements, so set this to true if your connection pool wraps PreparedStatements.
isNativeConnectionNecessaryForNativePreparedStatements
public boolean isNativeConnectionNecessaryForNativePreparedStatements()
从类复制的说明:NativeJdbcExtractorAdapter
Returnfalse
by default.
setNativeConnectionNecessaryForNativeCallableStatements
public void setNativeConnectionNecessaryForNativeCallableStatements(boolean nativeConnectionNecessary)
Set whether it is necessary to work on the native Connection to receive native CallableStatements. Default is "false". If true, the Connection will be unwrapped first to create a CallableStatement.This makes sense if you need to work with native CallableStatements from a pool that does not allow to extract the native JDBC objects from its wrappers but returns the native Connection on Statement.getConnection.
The standard SimpleNativeJdbcExtractor is unable to unwrap statements, so set this to true if your connection pool wraps CallableStatements.
isNativeConnectionNecessaryForNativeCallableStatements
public boolean isNativeConnectionNecessaryForNativeCallableStatements()
从类复制的说明:NativeJdbcExtractorAdapter
Returnfalse
by default.