## org.firebirdsql.pool
Class AbstractPingablePooledConnection

    java.lang.Object
      org.firebirdsql.pool.AbstractPingablePooledConnection

All Implemented Interfaces:
  PooledConnection, PooledObject, XStatementManager

Direct Known Subclasses:
  PingablePooledConnection

    public abstract class AbstractPingablePooledConnection

extends Object
implements PooledConnection, PooledObject, XStatementManager

This class implements `PooledConnection` interface.

Author:
  Roman Rokytskyy

Field Summary
`protected Connection` `jdbcConnection`

Constructor Summary
`protected` `AbstractPingablePooledConnection(Connection connection, boolean statementPooling, int maxStatements, boolean keepStatements)`
`protected` `AbstractPingablePooledConnection(Connection connection, String pingStatement, int pingInterval, boolean statementPooling, int maxStatements, boolean keepStatements)`

Method Summary
`void` `addConnectionEventListener(ConnectionEventListener listener)` Add connection listener to be notified about connection events.
`void` `close()` Close this pooled connection.
`protected void` `configureConnectionDefaults(Connection connection)` Configure default values for this connection.
`void` `connectionClosed(org.firebirdsql.pool.PooledConnectionHandler connection)` Notify connection owner about invocation of the `Connection.close()` operation on `PooledConnectionHandler` instance.
`void` `connectionCommitted(org.firebirdsql.pool.PooledConnectionHandler connection)` Notify this class that transaction was committed.
`void` `connectionErrorOccured(org.firebirdsql.pool.PooledConnectionHandler connection, SQLException ex)` Notify connection owner about the `SQLException` that happened during method invocation on the wrapped connection.
`void` `connectionRolledBack(org.firebirdsql.pool.PooledConnectionHandler connection)` Notify this class that transaction was rolled back.
`void` `deallocate()` Deallocate this object.
`Connection` `getConnection()` Get JDBC connection corresponding to this pooled connection instance.
`long` `getLastPingTime()` Get the time when connection was pinged last time.
`protected Logger` `getLogChannel()`
`PreparedStatement` `getPreparedStatement(String statement, int resultSetType, int resultSetConcurrency)` Handle `Connection.prepareStatement(String)` method call.
`protected void` `internalClose()` Close this connection.
`boolean` `isInPool()` Check whether this object is currently in pool or had been released to the application.
`boolean` `isKeepStatements()`
`boolean` `isStatementPooling()`
`boolean` `isValid()` Check if this pooled connection is still valid.
`boolean` `isValid(org.firebirdsql.pool.PooledConnectionHandler connection)` Check if specified connection is still valid.
`boolean` `ping()` Ping connection by executing a ping statement.
`org.firebirdsql.pool.XCachablePreparedStatement` `prepareStatement(String statement, int resultSetType, int resultSetConcurrency, boolean cached)` Prepare the specified statement and wrap it with cache notification wrapper.
`void` `removeConnectionEventListener(ConnectionEventListener listener)` Remove connection listener from this pooled connection.
`void` `setDefaultTransactionIsolation(int isolation)`
`void` `setInPool(boolean inPool)` Set the "inPool" flag to this object.
`void` `statementClosed(String statement, Object proxy)` Handle `Statement.close()` method.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface javax.sql.PooledConnection
`addStatementEventListener, removeStatementEventListener`

Field Detail

### jdbcConnection

    protected Connection jdbcConnection

Constructor Detail

### AbstractPingablePooledConnection

    protected AbstractPingablePooledConnection(Connection connection,
                                               boolean statementPooling,
                                               int maxStatements,
                                               boolean keepStatements)
                                        throws SQLException

Throws:
  `SQLException`

### AbstractPingablePooledConnection

    protected AbstractPingablePooledConnection(Connection connection,
                                               String pingStatement,
                                               int pingInterval,
                                               boolean statementPooling,
                                               int maxStatements,
                                               boolean keepStatements)
                                        throws SQLException

Throws:
  `SQLException`

Method Detail

### getLogChannel

    protected Logger getLogChannel()

### setDefaultTransactionIsolation

    public void setDefaultTransactionIsolation(int isolation)

### getLastPingTime

    public long getLastPingTime()

  Get the time when connection was pinged last time.

  Returns:
    time when connection was pinged last time.

### isStatementPooling

    public boolean isStatementPooling()

### isKeepStatements

    public boolean isKeepStatements()

### ping

    public boolean ping()

  Ping connection by executing a ping statement.

  Returns:
    `true` if connection was successfully pinged.

### isValid

    public boolean isValid()

  Check if this pooled connection is still valid.

  Specified by:
    `isValid` in interface `PooledObject`
  Returns:
    `true` if this pooled connection is still valid.

### isInPool

    public boolean isInPool()

  Check whether this object is currently in pool or had been released to the application.

  Specified by:
    `isInPool` in interface `PooledObject`
  Returns:
    `true` if the object is currently in pool.

### setInPool

    public void setInPool(boolean inPool)

  Set the "inPool" flag to this object. This method should be called only by the pool implementation.

  Specified by:
    `setInPool` in interface `PooledObject`
  Parameters:
    `inPool` - `true` if object is in pool, otherwise `false`.

### addConnectionEventListener

    public void addConnectionEventListener(ConnectionEventListener listener)

  Add connection listener to be notified about connection events.

  Specified by:
    `addConnectionEventListener` in interface `PooledConnection`
  Parameters:
    `listener` - listener to add.

### removeConnectionEventListener

    public void removeConnectionEventListener(ConnectionEventListener listener)

  Remove connection listener from this pooled connection.

  Specified by:
    `removeConnectionEventListener` in interface `PooledConnection`
  Parameters:
    `listener` - listener to remove.

### close

    public void close()
               throws SQLException

  Close this pooled connection. This operation closes physical connection to the database. Should not be called by applications directly.

  Specified by:
    `close` in interface `PooledConnection`
  Throws:
    `SQLException`

### internalClose

    protected void internalClose()
                          throws SQLException

  Close this connection.

  Throws:
    `SQLException` - if something went wrong.

### deallocate

    public void deallocate()

  Deallocate this object.

  Specified by:
    `deallocate` in interface `PooledObject`

### getConnection

    public Connection getConnection()
                             throws SQLException

  Get JDBC connection corresponding to this pooled connection instance.

  Specified by:
    `getConnection` in interface `PooledConnection`
  Returns:
    instance of `Connection`
  Throws:
    `SQLException` - if some error happened.

### configureConnectionDefaults

    protected void configureConnectionDefaults(Connection connection)
                                        throws SQLException

  Configure default values for this connection.

  Parameters:
    `connection` - instance of `Connection` to configure.
  Throws:
    `SQLException` - if something went wrong.

### getPreparedStatement

    public PreparedStatement getPreparedStatement(String statement,
                                                  int resultSetType,
                                                  int resultSetConcurrency)
                                           throws SQLException

  Handle `Connection.prepareStatement(String)` method call. This method check internal cache first and returns prepared statement if found. Otherwise, it prepares statement and caches it.

  Parameters:
    `statement` - statement to prepare.
    `resultSetType` - type of the result set.
    `resultSetConcurrency` - result set concurrency.
  Returns:
    instance of `PreparedStatement` corresponding to the `statement`.
  Throws:
    `SQLException` - if there was problem preparing statement.

### prepareStatement

    public org.firebirdsql.pool.XCachablePreparedStatement prepareStatement(String statement,
                                                                            int resultSetType,
                                                                            int resultSetConcurrency,
                                                                            boolean cached)
                                                                     throws SQLException

  Prepare the specified statement and wrap it with cache notification wrapper.

  Specified by:
    `prepareStatement` in interface `XStatementManager`
  Parameters:
    `statement` - sattement to prepare.
    `resultSetType` - type of result set
    `resultSetConcurrency` - result set concurrency
    `cached` - `true` if prepared statement will be cached.
  Returns:
    prepared and wrapped statement.
  Throws:
    `SQLException` - if underlying connection threw this exception.
  See Also:
    `Connection.prepareStatement(java.lang.String, int, int)`

### statementClosed

    public void statementClosed(String statement,
                                Object proxy)
                         throws SQLException

  Handle `Statement.close()` method. This implementation dereferences proxy in cache.

  Specified by:
    `statementClosed` in interface `XStatementManager`
  Parameters:
    `statement` - SQL statement corresponding to the proxy.
    `proxy` - proxy wrapping the connection.
  Throws:
    `SQLException` - if prepared statement cannot be added to the pool.

### connectionClosed

    public void connectionClosed(org.firebirdsql.pool.PooledConnectionHandler connection)
                          throws SQLException

  Notify connection owner about invocation of the `Connection.close()` operation on `PooledConnectionHandler` instance.

  Parameters:
    `connection` - instance of `PooledConnectionHandler` that initiated the call.
  Throws:
    `SQLException`

### connectionErrorOccured

    public void connectionErrorOccured(org.firebirdsql.pool.PooledConnectionHandler connection,
                                       SQLException ex)

  Notify connection owner about the `SQLException` that happened during method invocation on the wrapped connection.

  Parameters:
    `connection` - instance of `PooledConnectionHandler` that catched exception.
    `ex` - instance of `SQLException` that was thrown.

### isValid

    public boolean isValid(org.firebirdsql.pool.PooledConnectionHandler connection)

  Check if specified connection is still valid.

  Parameters:
    `connection` - instance of `PooledConnectionHandler` to check.
  Returns:
    `true` if connection owner is still valid, `false` otherwise.

### connectionCommitted

    public void connectionCommitted(org.firebirdsql.pool.PooledConnectionHandler connection)
                             throws SQLException

  Notify this class that transaction was committed.

  Parameters:
    `connection` - connection that was commited.
  Throws:
    `SQLException`
  See Also:
    `XConnectionManager.connectionCommitted(PooledConnectionHandler)`

### connectionRolledBack

    public void connectionRolledBack(org.firebirdsql.pool.PooledConnectionHandler connection)
                              throws SQLException

  Notify this class that transaction was rolled back.

  Parameters:
    `connection` - connection that was commited.
  Throws:
    `SQLException`
  See Also:
    `XConnectionManager.connectionRolledBack(PooledConnectionHandler)`

Copyright © 2001-2010. All Rights Reserved.