Class CommonsDbcpNativeJdbcExtractor


  • public class CommonsDbcpNativeJdbcExtractor
    extends java.lang.Object
    Partial (only the functionality we use) copy of CommonsDbcpNativeJdbcExtractor from Spring 4.3.9.

    Added while migrating to Spring 5.2.5. The class CommonsDbcpNativeJdbcExtractor was removed from spring and was not possible to use the suggested replacements/workarounds.

    The class contains also some methods copied from other spring 4.3.9 classes, also not available anymore:

    Implementation of the NativeJdbcExtractor interface for the Apache Commons DBCP connection pool, version 1.1 or higher.

    Returns the underlying native Connection, Statement, etc to application code instead of DBCP's wrapper implementations. The returned JDBC classes can then safely be cast, e.g. to oracle.jdbc.OracleConnection.

    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 that this version of CommonsDbcpNativeJdbcExtractor will work against the original Commons DBCP in org.apache.commons.dbcp as well as against Tomcat 5.5's relocated Commons DBCP version in the org.apache.tomcat.dbcp.dbcp package.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.sql.Connection getNativeConnection​(java.sql.Connection con)
      Method copied from NativeJdbcAdapter from spring 4.3.9 (removed in Spring 5.2.5).
      java.sql.PreparedStatement getNativePreparedStatement​(java.sql.PreparedStatement ps)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CommonsDbcpNativeJdbcExtractor

        public CommonsDbcpNativeJdbcExtractor()
    • Method Detail

      • getNativeConnection

        public java.sql.Connection getNativeConnection​(java.sql.Connection con)
                                                throws java.sql.SQLException
        Method copied from NativeJdbcAdapter from spring 4.3.9 (removed in Spring 5.2.5).

        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.

        Parameters:
        con -
        Returns:
        native connection
        Throws:
        java.sql.SQLException
        See Also:
        doGetNativeConnection(java.sql.Connection), ConnectionProxy, DataSourceUtils.getTargetConnection(java.sql.Connection), TransactionAwareDataSourceProxy, LazyConnectionDataSourceProxy
      • getNativePreparedStatement

        public java.sql.PreparedStatement getNativePreparedStatement​(java.sql.PreparedStatement ps)
                                                              throws java.sql.SQLException
        Throws:
        java.sql.SQLException