Package org.apache.commons.dbcp2

# Class Jdbc41Bridge

java.lang.Object
org.apache.commons.dbcp2.Jdbc41Bridge

public class Jdbc41Bridge extends Object
Defines bridge methods to JDBC 4.1 (Java 7 or above) methods to allow call sites to operate safely (without `AbstractMethodError`) when using a JDBC driver written for JDBC 4.0 (Java 6 or above).

There should be no need to this kind of code for JDBC 4.2 in Java 8 due to JDBC's use of default methods.

This should probably be moved or at least copied in some form to Apache Commons DbUtils.

Since:
  2.6.0

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Jdbc41Bridge()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static void`
  `abort(Connection connection, Executor executor)`
  Delegates to `Connection.abort(Executor)` without throwing an `AbstractMethodError`.
  `static void`
  `closeOnCompletion(Statement statement)`
  Delegates to `Statement.closeOnCompletion()` without throwing an `AbstractMethodError`.
  `static boolean`
  `generatedKeyAlwaysReturned(DatabaseMetaData databaseMetaData)`
  Delegates to `DatabaseMetaData.generatedKeyAlwaysReturned()` without throwing a `AbstractMethodError`.
  `static int`
  `getNetworkTimeout(Connection connection)`
  Delegates to `Connection.getNetworkTimeout()` without throwing an `AbstractMethodError`.
  `static <T> T`
  `getObject(ResultSet resultSet, int columnIndex, Class<T> type)`
  Delegates to `ResultSet.getObject(int, Class)` without throwing an `AbstractMethodError`.
  `static <T> T`
  `getObject(ResultSet resultSet, String columnLabel, Class<T> type)`
  Delegates to `ResultSet.getObject(String, Class)` without throwing an `AbstractMethodError`.
  `static Logger`
  `getParentLogger(CommonDataSource commonDataSource)`
  Delegates to `CommonDataSource.getParentLogger()` without throwing an `AbstractMethodError`.
  `static ResultSet`
  `getPseudoColumns(DatabaseMetaData databaseMetaData, String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern)`
  Delegates to `DatabaseMetaData.getPseudoColumns(String, String, String, String)` without throwing a `AbstractMethodError`.
  `static String`
  `getSchema(Connection connection)`
  Delegates to `Connection.getSchema()` without throwing an `AbstractMethodError`.
  `static boolean`
  `isCloseOnCompletion(Statement statement)`
  Delegates to `Statement.isCloseOnCompletion()` without throwing an `AbstractMethodError`.
  `static void`
  `setNetworkTimeout(Connection connection, Executor executor, int milliseconds)`
  Delegates to `Connection.setNetworkTimeout(Executor, int)` without throwing an `AbstractMethodError`.
  `static void`
  `setSchema(Connection connection, String schema)`
  Delegates to `Connection.setSchema(String)` without throwing an `AbstractMethodError`.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Jdbc41Bridge

    public Jdbc41Bridge()

- ## Method Details

  - ### abort

    public static void abort(Connection connection, Executor executor) throws SQLException
    Delegates to `Connection.abort(Executor)` without throwing an `AbstractMethodError`.

    If the JDBC driver does not implement `Connection.abort(Executor)`, then call `Connection.close()`.

    Parameters:
      `connection` - the receiver
      `executor` - See `Connection.abort(Executor)`.
    Throws:
      `SQLException` - See `Connection.abort(Executor)`.
    See Also:
      - `Connection.abort(Executor)`

  - ### closeOnCompletion

    public static void closeOnCompletion(Statement statement) throws SQLException
    Delegates to `Statement.closeOnCompletion()` without throwing an `AbstractMethodError`.

    If the JDBC driver does not implement `Statement.closeOnCompletion()`, then just check that the connection is closed to then throw an SQLException.

    Parameters:
      `statement` - See `Statement.closeOnCompletion()`
    Throws:
      `SQLException` - See `Statement.closeOnCompletion()`
    See Also:
      - `Statement.closeOnCompletion()`

  - ### generatedKeyAlwaysReturned

    public static boolean generatedKeyAlwaysReturned(DatabaseMetaData databaseMetaData) throws SQLException
    Delegates to `DatabaseMetaData.generatedKeyAlwaysReturned()` without throwing a `AbstractMethodError`.

    If the JDBC driver does not implement `DatabaseMetaData.generatedKeyAlwaysReturned()`, then return false.

    Parameters:
      `databaseMetaData` - See `DatabaseMetaData.generatedKeyAlwaysReturned()`
    Returns:
      See `DatabaseMetaData.generatedKeyAlwaysReturned()`
    Throws:
      `SQLException` - See `DatabaseMetaData.generatedKeyAlwaysReturned()`
    See Also:
      - `DatabaseMetaData.generatedKeyAlwaysReturned()`

  - ### getNetworkTimeout

    public static int getNetworkTimeout(Connection connection) throws SQLException
    Delegates to `Connection.getNetworkTimeout()` without throwing an `AbstractMethodError`.

    If the JDBC driver does not implement `Connection.getNetworkTimeout()`, then return 0.

    Parameters:
      `connection` - the receiver
    Returns:
      See `Connection.getNetworkTimeout()`
    Throws:
      `SQLException` - See `Connection.getNetworkTimeout()`
    See Also:
      - `Connection.getNetworkTimeout()`

  - ### getObject

    public static <T> T getObject(ResultSet resultSet, int columnIndex, Class<T> type) throws SQLException
    Delegates to `ResultSet.getObject(int, Class)` without throwing an `AbstractMethodError`.

    If the JDBC driver does not implement `ResultSet.getObject(int, Class)`, then return 0.

    Type Parameters:
      `T` - See `ResultSet.getObject(int, Class)`
    Parameters:
      `resultSet` - See `ResultSet.getObject(int, Class)`
      `columnIndex` - See `ResultSet.getObject(int, Class)`
      `type` - See `ResultSet.getObject(int, Class)`
    Returns:
      See `ResultSet.getObject(int, Class)`
    Throws:
      `SQLException` - See `ResultSet.getObject(int, Class)`
    See Also:
      - `ResultSet.getObject(int, Class)`

  - ### getObject

    public static <T> T getObject(ResultSet resultSet, String columnLabel, Class<T> type) throws SQLException
    Delegates to `ResultSet.getObject(String, Class)` without throwing an `AbstractMethodError`.
    Type Parameters:
      `T` - See `ResultSet.getObject(String, Class)`
    Parameters:
      `resultSet` - See `ResultSet.getObject(String, Class)`
      `columnLabel` - See `ResultSet.getObject(String, Class)`
      `type` - See `ResultSet.getObject(String, Class)`
    Returns:
      See `ResultSet.getObject(String, Class)`
    Throws:
      `SQLException` - See `ResultSet.getObject(String, Class)`
    See Also:
      - `ResultSet.getObject(int, Class)`

  - ### getParentLogger

    public static Logger getParentLogger(CommonDataSource commonDataSource) throws SQLFeatureNotSupportedException
    Delegates to `CommonDataSource.getParentLogger()` without throwing an `AbstractMethodError`.

    If the JDBC driver does not implement `CommonDataSource.getParentLogger()`, then return null.

    Parameters:
      `commonDataSource` - See `CommonDataSource.getParentLogger()`
    Returns:
      See `CommonDataSource.getParentLogger()`
    Throws:
      `SQLFeatureNotSupportedException` - See `CommonDataSource.getParentLogger()`

  - ### getPseudoColumns

    public static ResultSet getPseudoColumns(DatabaseMetaData databaseMetaData, String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException
    Delegates to `DatabaseMetaData.getPseudoColumns(String, String, String, String)` without throwing a `AbstractMethodError`.

    If the JDBC driver does not implement `DatabaseMetaData.getPseudoColumns(String, String, String, String)`, then return null.

    Parameters:
      `databaseMetaData` - the receiver
      `catalog` - See `DatabaseMetaData.getPseudoColumns(String, String, String, String)`
      `schemaPattern` - See `DatabaseMetaData.getPseudoColumns(String, String, String, String)`
      `tableNamePattern` - See `DatabaseMetaData.getPseudoColumns(String, String, String, String)`
      `columnNamePattern` - See `DatabaseMetaData.getPseudoColumns(String, String, String, String)`
    Returns:
      See `DatabaseMetaData.getPseudoColumns(String, String, String, String)`
    Throws:
      `SQLException` - See `DatabaseMetaData.getPseudoColumns(String, String, String, String)`
    See Also:
      - `DatabaseMetaData.getPseudoColumns(String, String, String, String)`

  - ### getSchema

    public static String getSchema(Connection connection) throws SQLException
    Delegates to `Connection.getSchema()` without throwing an `AbstractMethodError`.

    If the JDBC driver does not implement `Connection.getSchema()`, then return null.

    Parameters:
      `connection` - the receiver
    Returns:
      null for a JDBC 4 driver or a value per `Connection.getSchema()`.
    Throws:
      `SQLException` - See `Connection.getSchema()`.
    See Also:
      - `Connection.getSchema()`

  - ### isCloseOnCompletion

    public static boolean isCloseOnCompletion(Statement statement) throws SQLException
    Delegates to `Statement.isCloseOnCompletion()` without throwing an `AbstractMethodError`.

    If the JDBC driver does not implement `Statement.isCloseOnCompletion()`, then just check that the connection is closed to then throw an SQLException.

    Parameters:
      `statement` - See `Statement.isCloseOnCompletion()`
    Returns:
      See `Statement.isCloseOnCompletion()`
    Throws:
      `SQLException` - See `Statement.isCloseOnCompletion()`
    See Also:
      - `Statement.closeOnCompletion()`

  - ### setNetworkTimeout

    public static void setNetworkTimeout(Connection connection, Executor executor, int milliseconds) throws SQLException
    Delegates to `Connection.setNetworkTimeout(Executor, int)` without throwing an `AbstractMethodError`.

    If the JDBC driver does not implement `Connection.setNetworkTimeout(Executor, int)`, then do nothing.

    Parameters:
      `connection` - the receiver
      `executor` - See `Connection.setNetworkTimeout(Executor, int)`
      `milliseconds` - `Connection.setNetworkTimeout(Executor, int)`
    Throws:
      `SQLException` - `Connection.setNetworkTimeout(Executor, int)`
    See Also:
      - `Connection.setNetworkTimeout(Executor, int)`

  - ### setSchema

    public static void setSchema(Connection connection, String schema) throws SQLException
    Delegates to `Connection.setSchema(String)` without throwing an `AbstractMethodError`.

    If the JDBC driver does not implement `Connection.setSchema(String)`, then do nothing.

    Parameters:
      `connection` - the receiver
      `schema` - See `Connection.setSchema(String)`.
    Throws:
      `SQLException` - See `Connection.setSchema(String)`.
    See Also:
      - `Connection.setSchema(String)`