## org.firebirdsql.pool
Class BasicAbstractConnectionPool

    java.lang.Object
      org.firebirdsql.pool.AbstractConnectionPool
          org.firebirdsql.pool.BasicAbstractConnectionPool

All Implemented Interfaces:
  Serializable, Referenceable, CommonDataSource, ConnectionPoolDataSource, ConnectionPoolConfiguration, PooledObjectListener

Direct Known Subclasses:
  AbstractDriverConnectionPoolDataSource, AbstractFBConnectionPoolDataSource

    public abstract class BasicAbstractConnectionPool

extends AbstractConnectionPool
implements ConnectionPoolConfiguration, ConnectionPoolDataSource, Serializable, Referenceable

Base class for connection pool implementations. Main feature of this class is that it implements `ConnectionPoolConfiguration` interface and releives developers from creating getters and setters for pool configuration parameters. Additionally this class provides basic functionality for JNDI-enabled connection pools. No other functionality is available.

Author:
  Roman Rokytskyy
See Also:
  Serialized Form

Nested Class Summary

Nested classes/interfaces inherited from class org.firebirdsql.pool.AbstractConnectionPool
`AbstractConnectionPool.UserPasswordPair`

Constructor Summary
`protected` `BasicAbstractConnectionPool()` Create instance of this class.

Method Summary
`protected abstract BasicAbstractConnectionPool` `createObjectInstance()`
`static Object` `deserialize(byte[] data)`
`int` `getBlockingTimeout()` Get time during which `ConnectionPoolDataSource.getPooledConnection()` can block.
`ConnectionPoolConfiguration` `getConfiguration()` Get configuration of this data source.
`Reference` `getDefaultReference()` Get default JNDI reference for this datasource.
`int` `getIdleTimeout()` Deprecated. non-standard name, use `getMaxIdleTime()`
`abstract int` `getLoginTimeout()`
`abstract PrintWriter` `getLogWriter()`
`int` `getMaxConnections()` Deprecated. non-standard name, use `getMaxPoolSize()`
`int` `getMaxIdleTime()` Get time after which idle connections will be deallocated.
`int` `getMaxPoolSize()` Get maximum number of physical connections that can be simultaneously open.
`int` `getMaxStatements()`
`int` `getMinConnections()` Deprecated. non-standard name, use `getMinPoolSize()`
`int` `getMinPoolSize()` Get minimum number of open JDBC connections that will be created when pool is started.
`Object` `getObjectInstance(Object obj)` Get object instance for the specified name in the specified context.
`int` `getPingInterval()` Get time interval after which connection should be pinged.
`String` `getPingStatement()` Get SQL statement that will be used to ping connection.
`abstract PooledConnection` `getPooledConnection()`
`abstract PooledConnection` `getPooledConnection(String user, String password)`
`protected String` `getRefAddr(Reference ref, String type)`
`Reference` `getReference()` Get JDNI reference.
`int` `getRetryInterval()` Get interval of getting connections retries.
`boolean` `isKeepStatements()`
`boolean` `isPingable()` Check if this pool supports pingable connections.
`boolean` `isPooling()` Check if this connection pool uses connection pooling, or just implements JDBC 2.0 SE interfaces.
`boolean` `isStatementPooling()` Check if this connection pool provides also prepared statement pooling.
`static byte[]` `serialize(Object obj)`
`void` `setBlockingTimeout(int blockingTimeout)`
`void` `setIdleTimeout(int idleTimeout)` Deprecated. non-standard name, use `setMaxIdleTime(int)`
`void` `setKeepStatements(boolean keepStatements)`
`abstract void` `setLoginTimeout(int seconds)`
`abstract void` `setLogWriter(PrintWriter printWriter)`
`void` `setMaxConnections(int maxConnections)` Deprecated. non-standard name, use `setMaxPoolSize(int)`
`void` `setMaxIdleTime(int maxIdleTime)`
`void` `setMaxPoolSize(int maxPoolSize)`
`void` `setMaxStatements(int maxStatements)`
`void` `setMinConnections(int minConnections)` Deprecated. non-standard name, use `setMinPoolSize(int)`
`void` `setMinPoolSize(int minPoolSize)`
`void` `setPingInterval(int pingInterval)`
`void` `setPingStatement(String pingStatement)`
`void` `setPooling(boolean pooling)`
`void` `setReference(Reference reference)` Set JNDI reference for this data source.
`void` `setRetryInterval(int retryInterval)`
`void` `setStatementPooling(boolean statementPooling)`

Methods inherited from class org.firebirdsql.pool.AbstractConnectionPool
`finalize, getConnectionManager, getFreeSize, getLogger, getPooledConnection, getPoolName, getQueue, getTotalSize, getWorkingSize, physicalConnectionDeallocated, pooledObjectReleased, restart, shutdown`

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

Constructor Detail

### BasicAbstractConnectionPool

    protected BasicAbstractConnectionPool()

  Create instance of this class. Default constructor introduced to make it available to subclasses.

Method Detail

### getLoginTimeout

    public abstract int getLoginTimeout()
                                 throws SQLException

  Specified by:
    `getLoginTimeout` in interface `CommonDataSource`
  Throws:
    `SQLException`

### setLoginTimeout

    public abstract void setLoginTimeout(int seconds)
                                  throws SQLException

  Specified by:
    `setLoginTimeout` in interface `CommonDataSource`
  Throws:
    `SQLException`

### getLogWriter

    public abstract PrintWriter getLogWriter()
                                      throws SQLException

  Specified by:
    `getLogWriter` in interface `CommonDataSource`
  Throws:
    `SQLException`

### setLogWriter

    public abstract void setLogWriter(PrintWriter printWriter)
                               throws SQLException

  Specified by:
    `setLogWriter` in interface `CommonDataSource`
  Throws:
    `SQLException`

### getPooledConnection

    public abstract PooledConnection getPooledConnection()
                                                  throws SQLException

  Specified by:
    `getPooledConnection` in interface `ConnectionPoolDataSource`
  Throws:
    `SQLException`

### getPooledConnection

    public abstract PooledConnection getPooledConnection(String user,
                                                         String password)
                                                  throws SQLException

  Specified by:
    `getPooledConnection` in interface `ConnectionPoolDataSource`
  Throws:
    `SQLException`

### getConfiguration

    public ConnectionPoolConfiguration getConfiguration()

  Description copied from class: `AbstractConnectionPool`
  Get configuration of this data source.

  Specified by:
    `getConfiguration` in class `AbstractConnectionPool`
  Returns:
    instance of `ConnectionPoolConfiguration` describing this data source.

### getBlockingTimeout

    public int getBlockingTimeout()

  Description copied from interface: `ConnectionPoolConfiguration`
  Get time during which `ConnectionPoolDataSource.getPooledConnection()` can block. By default method blocks forever.

  Specified by:
    `getBlockingTimeout` in interface `ConnectionPoolConfiguration`
  Returns:
    pool blocking timeout in milliseconds, `Integer.MAX_VALUE` indicates blocking forever.

### setBlockingTimeout

    public void setBlockingTimeout(int blockingTimeout)

### getIdleTimeout

    public int getIdleTimeout()

  Deprecated. non-standard name, use `getMaxIdleTime()`

  Description copied from interface: `ConnectionPoolConfiguration`
  Get time after which idle connections will be deallocated.

  Specified by:
    `getIdleTimeout` in interface `ConnectionPoolConfiguration`
  Returns:
    idle timeout in milliseconds, `Integer.MAX_VALUE` indicates that idle connections are not removed.

### setIdleTimeout

    public void setIdleTimeout(int idleTimeout)

  Deprecated. non-standard name, use `setMaxIdleTime(int)`

### getMaxIdleTime

    public int getMaxIdleTime()

  Description copied from interface: `ConnectionPoolConfiguration`
  Get time after which idle connections will be deallocated.

  Specified by:
    `getMaxIdleTime` in interface `ConnectionPoolConfiguration`
  Returns:
    idle timeout in milliseconds, `Integer.MAX_VALUE` indicates that idle connections are not removed.

### setMaxIdleTime

    public void setMaxIdleTime(int maxIdleTime)

### getMaxConnections

    public int getMaxConnections()

  Deprecated. non-standard name, use `getMaxPoolSize()`

  Description copied from interface: `ConnectionPoolConfiguration`
  Get maximum number of physical connections that can be simultaneously open.

  Specified by:
    `getMaxConnections` in interface `ConnectionPoolConfiguration`
  Returns:
    maximum number of simultaneously open physical database connections, 0 if no limit exists.

### setMaxConnections

    public void setMaxConnections(int maxConnections)

  Deprecated. non-standard name, use `setMaxPoolSize(int)`

### getMaxPoolSize

    public int getMaxPoolSize()

  Description copied from interface: `ConnectionPoolConfiguration`
  Get maximum number of physical connections that can be simultaneously open.

  Specified by:
    `getMaxPoolSize` in interface `ConnectionPoolConfiguration`
  Returns:
    maximum number of simultaneously open physical database connections, 0 if no limit exists.

### setMaxPoolSize

    public void setMaxPoolSize(int maxPoolSize)

### getMinConnections

    public int getMinConnections()

  Deprecated. non-standard name, use `getMinPoolSize()`

  Description copied from interface: `ConnectionPoolConfiguration`
  Get minimum number of open JDBC connections that will be created when pool is started.

  Specified by:
    `getMinConnections` in interface `ConnectionPoolConfiguration`
  Returns:
    minimum number of open JDBC connections to open at startup.

### setMinConnections

    public void setMinConnections(int minConnections)

  Deprecated. non-standard name, use `setMinPoolSize(int)`

### getMinPoolSize

    public int getMinPoolSize()

  Description copied from interface: `ConnectionPoolConfiguration`
  Get minimum number of open JDBC connections that will be created when pool is started.

  Specified by:
    `getMinPoolSize` in interface `ConnectionPoolConfiguration`
  Returns:
    minimum number of open JDBC connections to open at startup.

### setMinPoolSize

    public void setMinPoolSize(int minPoolSize)

### getPingInterval

    public int getPingInterval()

  Description copied from interface: `ConnectionPoolConfiguration`
  Get time interval after which connection should be pinged.

  Specified by:
    `getPingInterval` in interface `ConnectionPoolConfiguration`
  Returns:
    number of milliseconds in the ping interval.

### setPingInterval

    public void setPingInterval(int pingInterval)

### getPingStatement

    public String getPingStatement()

  Description copied from interface: `ConnectionPoolConfiguration`
  Get SQL statement that will be used to ping connection. Ping SQL statement returns exactly one row without throwing an exception. Ping SQL statement must not influence the outcome of a transaction.

  Examples of ping SQL statements:

  - Oracle: `"SELECT CAST(1 AS INTEGER) FROM DUAL"`
  - Firebird: `"SELECT CAST(1 AS INTEGER) FROM RDB$DATABASE"`

  Specified by:
    `getPingStatement` in interface `ConnectionPoolConfiguration`
  Returns:
    SQL statement that will be used to ping connection.

### setPingStatement

    public void setPingStatement(String pingStatement)

### getRetryInterval

    public int getRetryInterval()

  Description copied from interface: `ConnectionPoolConfiguration`
  Get interval of getting connections retries. It might happen that pool contains no free connection. In order not to wait until connection is returned into the pool, pool will try to obtain connection again and again with the interval returned by this method. Default value is 1000 (1 sec).

  Specified by:
    `getRetryInterval` in interface `ConnectionPoolConfiguration`
  Returns:
    retry interval in milliseconds.

### setRetryInterval

    public void setRetryInterval(int retryInterval)

### isPingable

    public boolean isPingable()

  Description copied from interface: `ConnectionPoolConfiguration`
  Check if this pool supports pingable connections. Pingable connections are used to correctly check if connection is still alive or not.

  Specified by:
    `isPingable` in interface `ConnectionPoolConfiguration`
  Returns:
    `true` if this pool supports pingable connections.

### isPooling

    public boolean isPooling()

  Description copied from interface: `ConnectionPoolConfiguration`
  Check if this connection pool uses connection pooling, or just implements JDBC 2.0 SE interfaces. By default pooling is on. It might make sense to set pooling off to check performance degradation in test environment. It could be also used in the environment where physical connection must be closed right after usage, however using JDBC 2.0 SE interfaces is either a requirement or is simpler than standard `java.sql.Driver`.

  Specified by:
    `isPooling` in interface `ConnectionPoolConfiguration`
  Returns:
    `true` if pooling is enabled.

### setPooling

    public void setPooling(boolean pooling)

### isStatementPooling

    public boolean isStatementPooling()

  Description copied from interface: `ConnectionPoolConfiguration`
  Check if this connection pool provides also prepared statement pooling. By default prepared statement pooling is enabled, however there might be situations where statement pooling is not desired, for example in environments where database can quickly run out of handles and fast handle reuse is required.

  Specified by:
    `isStatementPooling` in interface `ConnectionPoolConfiguration`
  Returns:
    `true` if prepared statement pooling is enabled.

### setStatementPooling

    public void setStatementPooling(boolean statementPooling)

### isKeepStatements

    public boolean isKeepStatements()

### setKeepStatements

    public void setKeepStatements(boolean keepStatements)

### getMaxStatements

    public int getMaxStatements()

### setMaxStatements

    public void setMaxStatements(int maxStatements)

### createObjectInstance

    protected abstract BasicAbstractConnectionPool createObjectInstance()

### getObjectInstance

    public Object getObjectInstance(Object obj)
                             throws Exception

  Get object instance for the specified name in the specified context. This method constructs new datasource if `obj` represents `Reference`, whose factory class is equal to this class.

  Throws:
    `Exception`

### getRefAddr

    protected String getRefAddr(Reference ref,
                                String type)

### getReference

    public Reference getReference()

  Get JDNI reference.

  Specified by:
    `getReference` in interface `Referenceable`
  Returns:
    instance of `Reference`.

### setReference

    public void setReference(Reference reference)

  Set JNDI reference for this data source.

  Parameters:
    `reference` - JNDI reference.

### getDefaultReference

    public Reference getDefaultReference()

  Get default JNDI reference for this datasource. This method is called if datasource is used in non-JCA environment.

  Returns:
    instance of `Reference` containing all information that allows to reconstruct the datasource.

### serialize

    public static byte[] serialize(Object obj)

### deserialize

    public static Object deserialize(byte[] data)

Copyright © 2001-2010. All Rights Reserved.