接口 ConnectionLifecycleInterceptor


  • public interface ConnectionLifecycleInterceptor
    Implementors of this interface can be installed via the "connectionLifecycleInterceptors" configuration property and receive events and alter behavior of "lifecycle" methods on our connection implementation. The driver will create one instance of a given interceptor per-connection.
    • 方法概要

      所有方法 实例方法 抽象方法 
      修饰符和类型 方法 说明
      void close()
      Called when an application calls Connection.close(), before the driver processes its own internal logic for close.
      boolean commit()
      Called when an application calls Connection.commit(), before the driver processes its own internal logic for commit().
      void destroy()
      Called by the driver when this extension should release any resources it is holding and cleanup internally before the connection is closed.
      ConnectionLifecycleInterceptor init​(MysqlConnection conn, Properties props, Log log)
      Called once per connection that wants to use the extension The properties are the same ones passed in in the URL or arguments to Driver.connect() or DriverManager.getConnection().
      boolean rollback()
      Called when an application calls Connection.rollback(), before the driver processes its own internal logic for rollback().
      boolean rollback​(Savepoint s)
      Called when an application calls Connection.rollback(), before the driver processes its own internal logic for rollback().
      boolean setAutoCommit​(boolean flag)
      Called when an application calls Connection.setAutoCommit(), before the driver processes its own internal logic for setAutoCommit().
      boolean setDatabase​(String db)
      Called when an application calls Connection.setCatalog() or Connection.setSchema(), before the driver processes its own internal logic for these methods.
      boolean transactionBegun()
      Called when the driver has been told by the server that a transaction is now in progress (when one has not been currently in progress).
      boolean transactionCompleted()
      Called when the driver has been told by the server that a transaction has completed, and no transaction is currently in progress.
    • 方法详细资料

      • init

        ConnectionLifecycleInterceptor init​(MysqlConnection conn,
                                            Properties props,
                                            Log log)
        Called once per connection that wants to use the extension The properties are the same ones passed in in the URL or arguments to Driver.connect() or DriverManager.getConnection().
        参数:
        conn - the connection for which this extension is being created
        props - configuration values as passed to the connection. Note that in order to support javax.sql.DataSources, configuration properties specific to an interceptor must be passed via setURL() on the DataSource. Extension properties are not exposed via accessor/mutator methods on DataSources.
        log - logger instance
        返回:
        interceptor
      • destroy

        void destroy()
        Called by the driver when this extension should release any resources it is holding and cleanup internally before the connection is closed.
      • close

        void close()
            throws SQLException
        Called when an application calls Connection.close(), before the driver processes its own internal logic for close.
        抛出:
        SQLException - if an error occurs
      • commit

        boolean commit()
                throws SQLException
        Called when an application calls Connection.commit(), before the driver processes its own internal logic for commit(). Interceptors should return "true" if the driver should perform its own internal logic for commit(), or "false" if not.
        返回:
        "true" if the driver should perform its own internal logic for commit(), or "false" if not.
        抛出:
        SQLException - if an error occurs
      • rollback

        boolean rollback()
                  throws SQLException
        Called when an application calls Connection.rollback(), before the driver processes its own internal logic for rollback(). Interceptors should return "true" if the driver should perform its own internal logic for rollback(), or "false" if not.
        返回:
        "true" if the driver should perform its own internal logic for rollback(), or "false" if not.
        抛出:
        SQLException - if an error occurs
      • rollback

        boolean rollback​(Savepoint s)
                  throws SQLException
        Called when an application calls Connection.rollback(), before the driver processes its own internal logic for rollback(). Interceptors should return "true" if the driver should perform its own internal logic for rollback(), or "false" if not.
        参数:
        s - savepoint
        返回:
        "true" if the driver should perform its own internal logic for rollback(), or "false" if not.
        抛出:
        SQLException - if an error occurs
      • setAutoCommit

        boolean setAutoCommit​(boolean flag)
                       throws SQLException
        Called when an application calls Connection.setAutoCommit(), before the driver processes its own internal logic for setAutoCommit(). Interceptors should return "true" if the driver should perform its own internal logic for setAutoCommit(), or "false" if not.
        参数:
        flag - autocommit flag
        返回:
        "true" if the driver should perform its own internal logic for setAutoCommit(), or "false" if not.
        抛出:
        SQLException - if an error occurs
      • setDatabase

        boolean setDatabase​(String db)
                     throws SQLException
        Called when an application calls Connection.setCatalog() or Connection.setSchema(), before the driver processes its own internal logic for these methods. Interceptors should return "true" if the driver should perform its own internal logic for setCatalog() or setSchema(), or "false" if not.
        参数:
        db - database name
        返回:
        "true" if the driver should perform its own internal logic for setCatalog() or setSchema(), or "false" if not.
        抛出:
        SQLException - if an error occurs
      • transactionBegun

        boolean transactionBegun()
        Called when the driver has been told by the server that a transaction is now in progress (when one has not been currently in progress).
        返回:
        true if transaction is in progress
      • transactionCompleted

        boolean transactionCompleted()
        Called when the driver has been told by the server that a transaction has completed, and no transaction is currently in progress.
        返回:
        true if transaction is completed