|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.jdbc.support.nativejdbc.SimpleNativeJdbcExtractor
Simple implementation of the NativeJdbcExtractor interface. Assumes a pool that just wraps Connections but not Statements: In this case, the underlying native Connection can be retrieved by simply opening a Statement and invoking Statement.getConnection(). All other JDBC objects will be returned as passed in.
Known to work with Resin 2.1 and 3.0, but should work with any pool that does not wrap Statements. Note that the pool can still wrap PreparedStatements etc: The only requirement of this extractor is that java.sql.Statement does not get wrapped, returning the native Connection on getConnection().
Customize this extractor by setting the "nativeConnectionNecessaryForXxx" flags accordingly: If PreparedStatements and/or CallableStatements are wrapped by your pool, set the respective "nativeConnectionNecessaryForXxx" flags to true. If none of the statement types is wrapped, the defaults are fine.
Statement.getConnection()
Constructor Summary | |
SimpleNativeJdbcExtractor()
|
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. |
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. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public SimpleNativeJdbcExtractor()
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 void setNativeConnectionNecessaryForNativePreparedStatements(boolean nativeConnectionNecessary)
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.
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 void setNativeConnectionNecessaryForNativeCallableStatements(boolean nativeConnectionNecessary)
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.
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) throws java.sql.SQLException
NativeJdbcExtractor
getNativeConnection
in interface NativeJdbcExtractor
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
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 |