Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.mysql.jdbc.jdbc2.optional
Class MysqlPooledConnection  view MysqlPooledConnection download MysqlPooledConnection.java

java.lang.Object
  extended bycom.mysql.jdbc.jdbc2.optional.MysqlPooledConnection
All Implemented Interfaces:
javax.sql.PooledConnection

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
static int CONNECTION_CLOSED_EVENT
          The flag for a connection being closed.
static int CONNECTION_ERROR_EVENT
          The flag for an exception being thrown.
private  java.util.Hashtable eventListeners
           
private  java.sql.Connection logicalHandle
           
private  java.sql.Connection physicalConn
           
 
Constructor Summary
MysqlPooledConnection(java.sql.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.
 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

eventListeners

private java.util.Hashtable eventListeners

logicalHandle

private java.sql.Connection logicalHandle

physicalConn

private java.sql.Connection physicalConn
Constructor Detail

MysqlPooledConnection

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

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

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

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

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

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.