Top Description Fields Constructors Methods
org.hsqldb.jdbc.pool

public Class JDBCPooledConnection

extends Object
implements PooledConnection, JDBCConnectionEventListener
Class Inheritance
All Implemented Interfaces
org.hsqldb.jdbc.JDBCConnectionEventListener, javax.sql.PooledConnection
Known Direct Subclasses
org.hsqldb.jdbc.pool.JDBCXAConnection
Imports
java.sql.Connection, .SQLException, javax.sql.ConnectionEvent, .ConnectionEventListener, .PooledConnection, .StatementEventListener, org.hsqldb.jdbc.JDBCConnection, .JDBCConnectionEventListener, org.hsqldb.lib.OrderedHashSet

An implementations of PooledConnection for use by connection pooling software.

The class maintains a lifetime connection to the database. The getConnection() method establishes a lease on the lifetime connection and returns a special JDBCConnection (userConnection) that is valid until it is closed.

This class uses a dedicated HyperSQL method to guarantee each lease on the connection starts with the original state of the connection.

The ConnectionEventLister objects that have been registered with this PooledConnection are notified when each lease expires, or an unrecoverable error occurs on the connection to the database.

Author
Fred Toussi (fredt@users dot sourceforge.net)
Since
JDK 1.2, HSQLDB 2.0
Version
2.0.1

Field Summary

Modifier and TypeField and Description
protected JDBCConnection
protected boolean
protected OrderedHashSet<ConnectionEventListener>
protected JDBCConnection

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addConnectionEventListener(ConnectionEventListener listener)

Implements javax.sql.PooledConnection.addConnectionEventListener.

Registers the given event listener so that it will be notified when an event occurs on this PooledConnection object.

public void
addStatementEventListener(StatementEventListener listener)

Implements javax.sql.PooledConnection.addStatementEventListener.

Registers a StatementEventListener with this PooledConnection object.

public void
close()

Implements javax.sql.PooledConnection.close.

Closes the physical connection that this PooledConnection object represents.

public synchronized void
public synchronized void
public synchronized Connection
getConnection()

Implements javax.sql.PooledConnection.getConnection.

Creates and returns a Connection object that is a handle for the physical connection that this PooledConnection object represents.

public synchronized boolean

Returns:

boolean
isInUse
()

Returns true if getConnection() has been called and a leas has been given.

public synchronized void
release()

Force close the userConnection, and connection, no close event is fired.

public void
removeConnectionEventListener(ConnectionEventListener listener)

Implements javax.sql.PooledConnection.removeConnectionEventListener.

Removes the given event listener from the list of components that will be notified when an event occurs on this PooledConnection object.

public void
removeStatementEventListener(StatementEventListener listener)

Implements javax.sql.PooledConnection.removeStatementEventListener.

Removes the specified StatementEventListener from the list of components that will be notified when the driver detects that a PreparedStatement has been closed or is invalid.

public synchronized void
reset()

Force close the userConnection, no close event is fired.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

connectionback to summary
protected JDBCConnection connection
isInUseback to summary
protected boolean isInUse
listenersback to summary
protected OrderedHashSet<ConnectionEventListener> listeners
userConnectionback to summary
protected JDBCConnection userConnection

Constructor Detail

JDBCPooledConnectionback to summary
public JDBCPooledConnection(JDBCConnection connection)

Method Detail

addConnectionEventListenerback to summary
public void addConnectionEventListener(ConnectionEventListener listener)

Implements javax.sql.PooledConnection.addConnectionEventListener.

Doc from javax.sql.PooledConnection.addConnectionEventListener.

Registers the given event listener so that it will be notified when an event occurs on this PooledConnection object.

addStatementEventListenerback to summary
public void addStatementEventListener(StatementEventListener listener)

Implements javax.sql.PooledConnection.addStatementEventListener.

Doc from javax.sql.PooledConnection.addStatementEventListener.

Registers a StatementEventListener with this PooledConnection object. Components that wish to be notified when PreparedStatements created by the connection are closed or are detected to be invalid may use this method to register a StatementEventListener with this PooledConnection object.

closeback to summary
public void close() throws SQLException

Implements javax.sql.PooledConnection.close.

Doc from javax.sql.PooledConnection.close.

Closes the physical connection that this PooledConnection object represents. An application never calls this method directly; it is called by the connection pool module, or manager.

See the interface description for more information.

Exceptions
SQLException:
if a database access error occurs
connectionClosedback to summary
public synchronized void connectionClosed()

Implements org.hsqldb.jdbc.JDBCConnectionEventListener.connectionClosed.

connectionErrorOccurredback to summary
public synchronized void connectionErrorOccurred(SQLException e)

Implements org.hsqldb.jdbc.JDBCConnectionEventListener.connectionErrorOccurred.

getConnectionback to summary
public synchronized Connection getConnection() throws SQLException

Implements javax.sql.PooledConnection.getConnection.

Doc from javax.sql.PooledConnection.getConnection.

Creates and returns a Connection object that is a handle for the physical connection that this PooledConnection object represents. The connection pool manager calls this method when an application has called the method DataSource.getConnection and there are no PooledConnection objects available. See the interface description for more information.

Exceptions
SQLException:
if a database access error occurs
isInUseback to summary
public synchronized boolean isInUse()

Returns true if getConnection() has been called and a leas has been given.

Returns:boolean

boolean

releaseback to summary
public synchronized void release()

Force close the userConnection, and connection, no close event is fired.

removeConnectionEventListenerback to summary
public void removeConnectionEventListener(ConnectionEventListener listener)

Implements javax.sql.PooledConnection.removeConnectionEventListener.

Doc from javax.sql.PooledConnection.removeConnectionEventListener.

Removes the given event listener from the list of components that will be notified when an event occurs on this PooledConnection object.

removeStatementEventListenerback to summary
public void removeStatementEventListener(StatementEventListener listener)

Implements javax.sql.PooledConnection.removeStatementEventListener.

Doc from javax.sql.PooledConnection.removeStatementEventListener.

Removes the specified StatementEventListener from the list of components that will be notified when the driver detects that a PreparedStatement has been closed or is invalid.

resetback to summary
public synchronized void reset()

Force close the userConnection, no close event is fired.