org.apache.commons.dbcp

Class DelegatingConnection

public class DelegatingConnection extends AbandonedTrace implements Connection

A base delegating implementation of Connection.

All of the methods from the Connection interface simply check to see that the Connection is active, and call the corresponding method on the "delegate" provided in my constructor.

Extends AbandonedTrace to implement Connection tracking and logging of code which created the Connection. Tracking the Connection ensures that the AbandonedObjectPool can close this connection and recycle it if its pool of connections is nearing exhaustion and this connection's last usage is older than the removeAbandonedTimeout.

Version: $Revision: 1.19 $ $Date: 2004/03/06 13:35:31 $

Author: Rodney Waldhoff Glenn L. Nielsen James House Dirk Verbeeck

Constructor Summary
DelegatingConnection(Connection c)
Create a wrapper for the Connectin which traces this Connection in the AbandonedObjectPool.
DelegatingConnection(Connection c, AbandonedConfig config)
Create a wrapper for the Connection which traces the Statements created so that any unclosed Statements can be closed when this Connection is closed.
Method Summary
voidclearWarnings()
voidclose()
Closes the underlying connection, and close any Statements that were not explicitly closed.
voidcommit()
StatementcreateStatement()
StatementcreateStatement(int resultSetType, int resultSetConcurrency)
StatementcreateStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
booleanequals(Object obj)
booleangetAutoCommit()
StringgetCatalog()
ConnectiongetDelegate()
Returns my underlying Connection.
intgetHoldability()
ConnectiongetInnermostDelegate()
If my underlying Connection is not a DelegatingConnection, returns it, otherwise recursively invokes this method on my delegate.
DatabaseMetaDatagetMetaData()
intgetTransactionIsolation()
MapgetTypeMap()
SQLWarninggetWarnings()
inthashCode()
booleanisClosed()
booleanisReadOnly()
StringnativeSQL(String sql)
CallableStatementprepareCall(String sql)
CallableStatementprepareCall(String sql, int resultSetType, int resultSetConcurrency)
CallableStatementprepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
PreparedStatementprepareStatement(String sql)
PreparedStatementprepareStatement(String sql, int resultSetType, int resultSetConcurrency)
PreparedStatementprepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
PreparedStatementprepareStatement(String sql, int autoGeneratedKeys)
PreparedStatementprepareStatement(String sql, int[] columnIndexes)
PreparedStatementprepareStatement(String sql, String[] columnNames)
voidreleaseSavepoint(Savepoint savepoint)
voidrollback()
voidrollback(Savepoint savepoint)
voidsetAutoCommit(boolean autoCommit)
voidsetCatalog(String catalog)
voidsetDelegate(Connection c)
Sets my delegate.
voidsetHoldability(int holdability)
voidsetReadOnly(boolean readOnly)
SavepointsetSavepoint()
SavepointsetSavepoint(String name)
voidsetTransactionIsolation(int level)
voidsetTypeMap(Map map)

Constructor Detail

DelegatingConnection

public DelegatingConnection(Connection c)
Create a wrapper for the Connectin which traces this Connection in the AbandonedObjectPool.

Parameters: c the Connection to delegate all calls to.

DelegatingConnection

public DelegatingConnection(Connection c, AbandonedConfig config)

Deprecated: AbandonedConfig is now deprecated.

Create a wrapper for the Connection which traces the Statements created so that any unclosed Statements can be closed when this Connection is closed.

Parameters: Connection the Connection to delegate all calls to. AbandonedConfig the configuration for tracing abandoned objects

Method Detail

clearWarnings

public void clearWarnings()

close

public void close()
Closes the underlying connection, and close any Statements that were not explicitly closed.

commit

public void commit()

createStatement

public Statement createStatement()

createStatement

public Statement createStatement(int resultSetType, int resultSetConcurrency)

createStatement

public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)

equals

public boolean equals(Object obj)

getAutoCommit

public boolean getAutoCommit()

getCatalog

public String getCatalog()

getDelegate

public Connection getDelegate()
Returns my underlying Connection.

Returns: my underlying Connection.

getHoldability

public int getHoldability()

getInnermostDelegate

public Connection getInnermostDelegate()
If my underlying Connection is not a DelegatingConnection, returns it, otherwise recursively invokes this method on my delegate.

Hence this method will return the first delegate that is not a DelegatingConnection, or null when no non-DelegatingConnection delegate can be found by transversing this chain.

This method is useful when you may have nested DelegatingConnections, and you want to make sure to obtain a "genuine" Connection.

getMetaData

public DatabaseMetaData getMetaData()

getTransactionIsolation

public int getTransactionIsolation()

getTypeMap

public Map getTypeMap()

getWarnings

public SQLWarning getWarnings()

hashCode

public int hashCode()

isClosed

public boolean isClosed()

isReadOnly

public boolean isReadOnly()

nativeSQL

public String nativeSQL(String sql)

prepareCall

public CallableStatement prepareCall(String sql)

prepareCall

public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency)

prepareCall

public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)

prepareStatement

public PreparedStatement prepareStatement(String sql)

prepareStatement

public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)

prepareStatement

public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)

prepareStatement

public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)

prepareStatement

public PreparedStatement prepareStatement(String sql, int[] columnIndexes)

prepareStatement

public PreparedStatement prepareStatement(String sql, String[] columnNames)

releaseSavepoint

public void releaseSavepoint(Savepoint savepoint)

rollback

public void rollback()

rollback

public void rollback(Savepoint savepoint)

setAutoCommit

public void setAutoCommit(boolean autoCommit)

setCatalog

public void setCatalog(String catalog)

setDelegate

public void setDelegate(Connection c)
Sets my delegate.

setHoldability

public void setHoldability(int holdability)

setReadOnly

public void setReadOnly(boolean readOnly)

setSavepoint

public Savepoint setSavepoint()

setSavepoint

public Savepoint setSavepoint(String name)

setTransactionIsolation

public void setTransactionIsolation(int level)

setTypeMap

public void setTypeMap(Map map)
Copyright © 2001-2003 Apache Software Foundation. Documenation generated February 19 2008.