Package java.sql

Interface Wrapper

All Known Subinterfaces:
CallableStatement, Connection, DatabaseMetaData, DataSource, ParameterMetaData, PreparedStatement, ResultSet, ResultSetMetaData, RowSet, RowSetMetaData, Statement
All Known Implementing Classes:
JDBCConnection, JDBCDatabaseMetaData, JDBCPreparedStatement, JDBCResultSet, JDBCResultSetMetaData, JDBCStatement

public interface Wrapper
This class is an actual usage of the wrapper pattern for JDBC classes. Developers can get the delegate instance when the instance may be a proxy class.
Since:
1.6
  • Method Summary

    Modifier and Type Method Description
    boolean isWrapperFor​(Class<?> iface)
    If the caller is a wrapper of the class or implements the given interface, the methods return false and vice versa.
    <T> T unwrap​(Class<T> iface)
    Returns an object that implements the given interface.
  • Method Details

    • unwrap

      <T> T unwrap​(Class<T> iface) throws SQLException
      Returns an object that implements the given interface. If the caller is not a wrapper, a SQLException will be thrown.
      Parameters:
      iface - - the class that defines the interface
      Returns:
      - an object that implements the interface
      Throws:
      SQLException - - if there is no object implementing the specific interface
    • isWrapperFor

      boolean isWrapperFor​(Class<?> iface) throws SQLException
      If the caller is a wrapper of the class or implements the given interface, the methods return false and vice versa.
      Parameters:
      iface - - the class that defines the interface
      Returns:
      - true if the instance implements the interface
      Throws:
      SQLException - - when an error occurs when judges the object