org.springframework.jdbc.support.nativejdbc
Class XAPoolNativeJdbcExtractor

java.lang.Object
  extended byorg.springframework.jdbc.support.nativejdbc.XAPoolNativeJdbcExtractor
All Implemented Interfaces:
NativeJdbcExtractor

public class XAPoolNativeJdbcExtractor
extends java.lang.Object
implements NativeJdbcExtractor

Implementation of the NativeJdbcExtractor interface for ObjectWeb's XAPool connection pool. Returns underlying native Connections and native PreparedStatements to application code instead of XAPool's wrapper implementations; unwraps the Connection for native Statements and native CallableStatements. The returned JDBC classes can then safely be cast, e.g. to OracleResultSet.

This NativeJdbcExtractor can be set just to allow working with a XAPool DataSource: If a given object is not an XAPool wrapper, it will be returned as-is.

Since:
06.02.2004
Author:
Juergen Hoeller

Constructor Summary
XAPoolNativeJdbcExtractor()
           
 
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

XAPoolNativeJdbcExtractor

public XAPoolNativeJdbcExtractor()
Method Detail

isNativeConnectionNecessaryForNativeStatements

public boolean isNativeConnectionNecessaryForNativeStatements()
Description copied from interface: NativeJdbcExtractor
Return whether it is necessary to work on the native Connection to receive native Statements.

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.

Specified by:
isNativeConnectionNecessaryForNativeStatements in interface NativeJdbcExtractor

isNativeConnectionNecessaryForNativePreparedStatements

public boolean isNativeConnectionNecessaryForNativePreparedStatements()
Description copied from interface: NativeJdbcExtractor
Return whether it is necessary to work on the native Connection to receive native PreparedStatements.

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.

Specified by:
isNativeConnectionNecessaryForNativePreparedStatements in interface NativeJdbcExtractor

isNativeConnectionNecessaryForNativeCallableStatements

public boolean isNativeConnectionNecessaryForNativeCallableStatements()
Description copied from interface: NativeJdbcExtractor
Return whether it is necessary to work on the native Connection to receive native CallableStatements.

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.

Specified by:
isNativeConnectionNecessaryForNativeCallableStatements in interface NativeJdbcExtractor

getNativeConnection

public java.sql.Connection getNativeConnection(java.sql.Connection con)
                                        throws java.sql.SQLException
Description copied from interface: NativeJdbcExtractor
Retrieve the underlying native JDBC Connection for the given Connection. Supposed to return the given Connection if not capable of unwrapping.

Specified by:
getNativeConnection in interface NativeJdbcExtractor
Parameters:
con - the Connection handle, potentially wrapped by a connection pool
Returns:
the underlying native JDBC Connection, if possible; else, the original Connection
Throws:
java.sql.SQLException - if thrown by JDBC methods

getNativeConnectionFromStatement

public java.sql.Connection getNativeConnectionFromStatement(java.sql.Statement stmt)
                                                     throws java.sql.SQLException
Description copied from interface: NativeJdbcExtractor
Retrieve the underlying native JDBC Connection for the given Statement. Supposed to return the Statement.getConnection if not capable of unwrapping.

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.

Specified by:
getNativeConnectionFromStatement in interface NativeJdbcExtractor
Parameters:
stmt - the Statement handle, potentially wrapped by a connection pool
Returns:
the underlying native JDBC Connection, if possible; else, the original Connection
Throws:
java.sql.SQLException - if thrown by JDBC methods

getNativeStatement

public java.sql.Statement getNativeStatement(java.sql.Statement stmt)
                                      throws java.sql.SQLException
Description copied from interface: NativeJdbcExtractor
Retrieve the underlying native JDBC Statement for the given Statement. Supposed to return the given Statement if not capable of unwrapping.

Specified by:
getNativeStatement in interface NativeJdbcExtractor
Parameters:
stmt - the Statement handle, potentially wrapped by a connection pool
Returns:
the underlying native JDBC Statement, if possible; else, the original Connection
Throws:
java.sql.SQLException - if thrown by JDBC methods

getNativePreparedStatement

public java.sql.PreparedStatement getNativePreparedStatement(java.sql.PreparedStatement ps)
                                                      throws java.sql.SQLException
Description copied from interface: NativeJdbcExtractor
Retrieve the underlying native JDBC PreparedStatement for the given statement. Supposed to return the given PreparedStatement if not capable of unwrapping.

Specified by:
getNativePreparedStatement in interface NativeJdbcExtractor
Parameters:
ps - the PreparedStatement handle, potentially wrapped by a connection pool
Returns:
the underlying native JDBC PreparedStatement, if possible; else, the original Connection
Throws:
java.sql.SQLException - if thrown by JDBC methods

getNativeCallableStatement

public java.sql.CallableStatement getNativeCallableStatement(java.sql.CallableStatement cs)
                                                      throws java.sql.SQLException
Description copied from interface: NativeJdbcExtractor
Retrieve the underlying native JDBC CallableStatement for the given statement. Supposed to return the given CallableStatement if not capable of unwrapping.

Specified by:
getNativeCallableStatement in interface NativeJdbcExtractor
Parameters:
cs - the CallableStatement handle, potentially wrapped by a connection pool
Returns:
the underlying native JDBC CallableStatement, if possible; else, the original Connection
Throws:
java.sql.SQLException - if thrown by JDBC methods

getNativeResultSet

public java.sql.ResultSet getNativeResultSet(java.sql.ResultSet rs)
                                      throws java.sql.SQLException
Description copied from interface: NativeJdbcExtractor
Retrieve the underlying native JDBC ResultSet for the given statement. Supposed to return the given ResultSet if not capable of unwrapping.

Specified by:
getNativeResultSet in interface NativeJdbcExtractor
Parameters:
rs - the ResultSet handle, potentially wrapped by a connection pool
Returns:
the underlying native JDBC ResultSet, if possible; else, the original Connection
Throws:
java.sql.SQLException - if thrown by JDBC methods


Copyright (C) 2003-2004 The Spring Framework Project.