Package com.mysql.cj.jdbc
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 Summary
Fields Modifier and Type Field Description static int
CONNECTION_CLOSED_EVENT
The flag for a connection being closed.static int
CONNECTION_ERROR_EVENT
The flag for an exception being thrown. -
Constructor Summary
Constructors Constructor Description MysqlPooledConnection(JdbcConnection connection)
Construct a new MysqlPooledConnection and set instance variables -
Method Summary
Modifier and Type Method Description void
addConnectionEventListener(javax.sql.ConnectionEventListener connectioneventlistener)
void
addStatementEventListener(javax.sql.StatementEventListener listener)
protected void
callConnectionEventListeners(int eventType, java.sql.SQLException sqlException)
Notifies all registered ConnectionEventListeners of ConnectionEvents.void
close()
Invoked by the container (not the client), and should close the physical connection.java.sql.Connection
getConnection()
protected java.sql.Connection
getConnection(boolean resetServerState, boolean forXa)
protected ExceptionInterceptor
getExceptionInterceptor()
protected static MysqlPooledConnection
getInstance(JdbcConnection connection)
void
removeConnectionEventListener(javax.sql.ConnectionEventListener connectioneventlistener)
void
removeStatementEventListener(javax.sql.StatementEventListener listener)
-
Field Details
-
CONNECTION_ERROR_EVENT
public static final int CONNECTION_ERROR_EVENTThe flag for an exception being thrown.- See Also:
- Constant Field Values
-
CONNECTION_CLOSED_EVENT
public static final int CONNECTION_CLOSED_EVENTThe flag for a connection being closed.- See Also:
- Constant Field Values
-
-
Constructor Details
-
MysqlPooledConnection
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 interfacejavax.sql.PooledConnection
-
removeConnectionEventListener
public void removeConnectionEventListener(javax.sql.ConnectionEventListener connectioneventlistener)- Specified by:
removeConnectionEventListener
in interfacejavax.sql.PooledConnection
-
getConnection
public java.sql.Connection getConnection() throws java.sql.SQLException- Specified by:
getConnection
in interfacejavax.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.SQLExceptionInvoked 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 interfacejavax.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 calledsqlException
- the exception being thrown
-
getExceptionInterceptor
-
addStatementEventListener
public void addStatementEventListener(javax.sql.StatementEventListener listener)- Specified by:
addStatementEventListener
in interfacejavax.sql.PooledConnection
-
removeStatementEventListener
public void removeStatementEventListener(javax.sql.StatementEventListener listener)- Specified by:
removeStatementEventListener
in interfacejavax.sql.PooledConnection
-