org.apache.cayenne.conn
Class PooledConnectionImpl

java.lang.Object
  extended by org.apache.cayenne.conn.PooledConnectionImpl
All Implemented Interfaces:
PooledConnection

public class PooledConnectionImpl
extends Object
implements PooledConnection

PooledConnectionImpl is an implementation of a pooling wrapper for the database connection as per JDBC3 spec. Most of the modern JDBC drivers should have its own implementation that may be used instead of this class.


Constructor Summary
protected PooledConnectionImpl()
           
  PooledConnectionImpl(DataSource connectionSource, String userName, String password)
          Creates new PooledConnection
 
Method Summary
 void addConnectionEventListener(ConnectionEventListener listener)
           
 void addStatementEventListener(StatementEventListener listener)
           
 void close()
           
protected  void connectionClosedNotification()
          Creates and sends an event to listeners when a user closes java.sql.Connection object belonging to this PooledConnection.
 void connectionErrorNotification(SQLException exception)
          This method creates and sents an event to listeners when an error occurs in the underlying connection.
 Connection getConnection()
           
 void reconnect()
           
 void removeConnectionEventListener(ConnectionEventListener listener)
           
 void removeStatementEventListener(StatementEventListener listener)
           
protected  void returnConnectionToThePool()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PooledConnectionImpl

protected PooledConnectionImpl()

PooledConnectionImpl

public PooledConnectionImpl(DataSource connectionSource,
                            String userName,
                            String password)
Creates new PooledConnection

Method Detail

reconnect

public void reconnect()
               throws SQLException
Throws:
SQLException

addConnectionEventListener

public void addConnectionEventListener(ConnectionEventListener listener)
Specified by:
addConnectionEventListener in interface PooledConnection

removeConnectionEventListener

public void removeConnectionEventListener(ConnectionEventListener listener)
Specified by:
removeConnectionEventListener in interface PooledConnection

close

public void close()
           throws SQLException
Specified by:
close in interface PooledConnection
Throws:
SQLException

getConnection

public Connection getConnection()
                         throws SQLException
Specified by:
getConnection in interface PooledConnection
Throws:
SQLException

returnConnectionToThePool

protected void returnConnectionToThePool()
                                  throws SQLException
Throws:
SQLException

connectionErrorNotification

public void connectionErrorNotification(SQLException exception)
This method creates and sents an event to listeners when an error occurs in the underlying connection. Listeners can have special logic to analyze the error and do things like closing this PooledConnection (if the error is fatal), etc...


connectionClosedNotification

protected void connectionClosedNotification()
Creates and sends an event to listeners when a user closes java.sql.Connection object belonging to this PooledConnection.


addStatementEventListener

public void addStatementEventListener(StatementEventListener listener)
Specified by:
addStatementEventListener in interface PooledConnection
Since:
3.0

removeStatementEventListener

public void removeStatementEventListener(StatementEventListener listener)
Specified by:
removeStatementEventListener in interface PooledConnection
Since:
3.0


Copyright © 2001-2011 Apache Cayenne. All Rights Reserved.