MySQL Connector/J size='-1'>5.0.8

com.mysql.jdbc.jdbc2.optional
Class MysqlPooledConnection

java.lang.Object
  extended bycom.mysql.jdbc.jdbc2.optional.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

Author:
Todd Wolff
See Also:
PooledConnection, org.gjt.mm.mysql.jdbc2.optional.LogicalHandle

Field Summary
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
MysqlPooledConnection(Connection connection)
          Construct a new MysqlPooledConnection and set instance variables
 
Method Summary
 void addConnectionEventListener(javax.sql.ConnectionEventListener connectioneventlistener)
          Adds ConnectionEventListeners to a hash table to be used for notification of ConnectionEvents
protected  void callListener(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()
          Invoked by the container.
protected  java.sql.Connection getConnection(boolean resetServerState, boolean forXa)
           
 void removeConnectionEventListener(javax.sql.ConnectionEventListener connectioneventlistener)
          Removes ConnectionEventListeners from hash table used for notification of ConnectionEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONNECTION_ERROR_EVENT

public static final int CONNECTION_ERROR_EVENT
The flag for an exception being thrown.

See Also:
Constant Field Values

CONNECTION_CLOSED_EVENT

public static final int CONNECTION_CLOSED_EVENT
The flag for a connection being closed.

See Also:
Constant Field Values
Constructor Detail

MysqlPooledConnection

public MysqlPooledConnection(Connection connection)
Construct a new MysqlPooledConnection and set instance variables

Parameters:
connection - physical connection to db
Method Detail

addConnectionEventListener

public void addConnectionEventListener(javax.sql.ConnectionEventListener connectioneventlistener)
Adds ConnectionEventListeners to a hash table to be used for notification of ConnectionEvents

Specified by:
addConnectionEventListener in interface javax.sql.PooledConnection
Parameters:
connectioneventlistener - listener to be notified with ConnectionEvents

removeConnectionEventListener

public void removeConnectionEventListener(javax.sql.ConnectionEventListener connectioneventlistener)
Removes ConnectionEventListeners from hash table used for notification of ConnectionEvents

Specified by:
removeConnectionEventListener in interface javax.sql.PooledConnection
Parameters:
connectioneventlistener - listener to be removed

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Invoked by the container. Return a logicalHandle object that wraps a physical connection.

Specified by:
getConnection in interface javax.sql.PooledConnection
Throws:
java.sql.SQLException
See Also:
java.sql.DataSource#getConnection()

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
See Also:
java.sql.DataSource#close()

callListener

protected void callListener(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

MySQL Connector/J size='-1'>5.0.8