Class MysqlPooledConnection

java.lang.Object
com.mysql.cj.jdbc.MysqlPooledConnection
All Implemented Interfaces:
javax.sql.PooledConnection
Direct Known Subclasses:
MysqlXAConnection, SuspendableXAConnection

public class MysqlPooledConnection
extends java.lang.Object
implements javax.sql.PooledConnection
This class is used to wrap and return a physical connection within a logical handle. It also registers and notifies ConnectionEventListeners of any ConnectionEvents
  • Field Details

  • Constructor Details

    • MysqlPooledConnection

      public MysqlPooledConnection​(JdbcConnection connection)
      Construct a new MysqlPooledConnection and set instance variables
      Parameters:
      connection - physical connection to db
  • Method Details

    • getInstance

      protected static MysqlPooledConnection getInstance​(JdbcConnection connection) throws java.sql.SQLException
      Throws:
      java.sql.SQLException
    • addConnectionEventListener

      public void addConnectionEventListener​(javax.sql.ConnectionEventListener connectioneventlistener)
      Specified by:
      addConnectionEventListener in interface javax.sql.PooledConnection
    • removeConnectionEventListener

      public void removeConnectionEventListener​(javax.sql.ConnectionEventListener connectioneventlistener)
      Specified by:
      removeConnectionEventListener in interface javax.sql.PooledConnection
    • getConnection

      public java.sql.Connection getConnection() throws java.sql.SQLException
      Specified by:
      getConnection in interface javax.sql.PooledConnection
      Throws:
      java.sql.SQLException
    • getConnection

      protected java.sql.Connection getConnection​(boolean resetServerState, boolean forXa) throws java.sql.SQLException
      Throws:
      java.sql.SQLException
    • close

      public void close() throws java.sql.SQLException
      Invoked by the container (not the client), and should close the physical connection. This will be called if the pool is destroyed or the connectionEventListener receives a connectionErrorOccurred event.
      Specified by:
      close in interface javax.sql.PooledConnection
      Throws:
      java.sql.SQLException
    • callConnectionEventListeners

      protected void callConnectionEventListeners​(int eventType, java.sql.SQLException sqlException)
      Notifies all registered ConnectionEventListeners of ConnectionEvents. Instantiates a new ConnectionEvent which wraps sqlException and invokes either connectionClose or connectionErrorOccurred on listener as appropriate.
      Parameters:
      eventType - value indicating whether connectionClosed or connectionErrorOccurred called
      sqlException - the exception being thrown
    • getExceptionInterceptor

      protected ExceptionInterceptor getExceptionInterceptor()
    • addStatementEventListener

      public void addStatementEventListener​(javax.sql.StatementEventListener listener)
      Specified by:
      addStatementEventListener in interface javax.sql.PooledConnection
    • removeStatementEventListener

      public void removeStatementEventListener​(javax.sql.StatementEventListener listener)
      Specified by:
      removeStatementEventListener in interface javax.sql.PooledConnection