org.firebirdsql.pool

Class AbstractDriverConnectionPoolDataSource

Implemented Interfaces:
ConnectionEventListener, ConnectionPoolDataSource, ConnectionPoolConfiguration, PooledConnectionEventListener, Referenceable, Serializable, PooledObjectListener

public abstract class AbstractDriverConnectionPoolDataSource
extends BasicAbstractConnectionPool
implements ConnectionPoolDataSource, PooledConnectionEventListener

Generic implementation of javax.sql.ConnectionPoolDataSource that uses java.sql.DriverManager to open physical connections to the database.
Author:
Roman Rokytskyy

Nested Class Summary

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

AbstractConnectionPool.UserPasswordPair

Field Summary

protected static String
DRIVER_CLASS_NAME
static AbstractConnectionPool.UserPasswordPair
EMPTY_USER_PASSWORD
protected static String
JDBC_URL
protected static String
PROPERTIES

Constructor Summary

AbstractDriverConnectionPoolDataSource()
Create instance of this class.

Method Summary

void
connectionClosed(ConnectionEvent connectionEvent)
Notify about connection being closed.
void
connectionErrorOccurred(ConnectionEvent event)
Notify about serious error when using the connection.
protected BasicAbstractConnectionPool
createObjectInstance()
Create instance of this data source.
protected PooledConnectionManager
getConnectionManager()
Get connection manager that will allocate physical connections to the database.
Reference
getDefaultReference()
Get default JNDI reference for this instance.
String
getDriverClassName()
int
getFreeSize()
Get number of free connections in this pool.
String
getIsolation()
String
getJdbcUrl()
PrintWriter
getLogWriter()
protected org.firebirdsql.logging.Logger
getLogger()
Get logger for this instance.
int
getLoginTimeout()
Get login timeout.
protected String
getPoolName()
Get name of this connection pool.
PooledConnection
getPooledConnection()
Get pooled connection.
PooledConnection
getPooledConnection(String user, String password)
Get pooled connection for the specified user name and password.
protected PooledObject
getPooledConnection(org.firebirdsql.pool.PooledConnectionQueue queue)
Get pooled connection from the pooled queue.
Properties
getProperties()
String
getProperty(String name)
int
getTotalSize()
Get total size of physical connections opened to the database.
int
getTransactionIsolationLevel()
int
getWorkingSize()
Get number of connections that are in use.
void
physicalConnectionClosed(ConnectionEvent connectionEvent)
Notify about physical connection being closed.
void
physicalConnectionDeallocated(ConnectionEvent connectionEvent)
Notify about the deallocation of the physical connection.
protected Object
processObjectInstance(AbstractDriverConnectionPoolDataSource ds, Object obj)
void
setDriverClassName(String driverClassName)
void
setIsolation(String isolation)
void
setJdbcUrl(String jdbcUrl)
void
setLogWriter(PrintWriter out)
void
setLoginTimeout(int seconds)
Set login timeout for new connection.
void
setProperties(Properties properties)
Set JDBC properties that will be passed when opening a connection.
void
setProperty(String name, String value)
void
setTransactionIsolationLevel(int transactionIsolation)

Methods inherited from class org.firebirdsql.pool.BasicAbstractConnectionPool

createObjectInstance, deserialize, getBlockingTimeout, getConfiguration, getDefaultReference, getIdleTimeout, getLogWriter, getLoginTimeout, getMaxConnections, getMaxIdleTime, getMaxPoolSize, getMaxStatements, getMinConnections, getMinPoolSize, getObjectInstance, getPingInterval, getPingStatement, getPooledConnection, getPooledConnection, getRefAddr, getReference, getRetryInterval, isKeepStatements, isPingable, isPooling, isStatementPooling, serialize, setBlockingTimeout, setIdleTimeout, setKeepStatements, setLogWriter, setLoginTimeout, setMaxConnections, setMaxIdleTime, setMaxPoolSize, setMaxStatements, setMinConnections, setMinPoolSize, setPingInterval, setPingStatement, setPooling, setReference, setRetryInterval, setStatementPooling

Methods inherited from class org.firebirdsql.pool.AbstractConnectionPool

finalize, getConfiguration, getConnectionManager, getFreeSize, getLogger, getPoolName, getPooledConnection, getQueue, getTotalSize, getWorkingSize, physicalConnectionDeallocated, pooledObjectReleased, restart, shutdown

Field Details

DRIVER_CLASS_NAME

protected static final String DRIVER_CLASS_NAME

EMPTY_USER_PASSWORD

public static final AbstractConnectionPool.UserPasswordPair EMPTY_USER_PASSWORD

JDBC_URL

protected static final String JDBC_URL

PROPERTIES

protected static final String PROPERTIES

Constructor Details

AbstractDriverConnectionPoolDataSource

public AbstractDriverConnectionPoolDataSource()
Create instance of this class.

Method Details

connectionClosed

public void connectionClosed(ConnectionEvent connectionEvent)
Notify about connection being closed.
Parameters:
connectionEvent - instance of ConnectionEvent.

connectionErrorOccurred

public void connectionErrorOccurred(ConnectionEvent event)
Notify about serious error when using the connection. Currently these events are ignored.
Parameters:
event - instance of ConnectionEvent containing information about an error.

createObjectInstance

protected BasicAbstractConnectionPool createObjectInstance()
Create instance of this data source.
Overrides:
createObjectInstance in interface BasicAbstractConnectionPool

getConnectionManager

protected PooledConnectionManager getConnectionManager()
            throws SQLException
Get connection manager that will allocate physical connections to the database.
Overrides:
getConnectionManager in interface AbstractConnectionPool
Returns:
instance of PooledConnectionManager class.

getDefaultReference

public Reference getDefaultReference()
Get default JNDI reference for this instance.
Overrides:
getDefaultReference in interface BasicAbstractConnectionPool

getDriverClassName

public String getDriverClassName()

getFreeSize

public int getFreeSize()
            throws SQLException
Get number of free connections in this pool. This method returns the number of free open connections to the specified database. It might return 0, but this does not mean that next request will block. This will happen only if getMaxSize() != 0 && getMaxSize() == getWorkingSize(), meaning that we have allocated maximum number of connections and all of them are in use.
Overrides:
getFreeSize in interface AbstractConnectionPool
Returns:
number of free connections left.

getIsolation

public String getIsolation()

getJdbcUrl

public String getJdbcUrl()

getLogWriter

public PrintWriter getLogWriter()
Overrides:
getLogWriter in interface BasicAbstractConnectionPool

getLogger

protected org.firebirdsql.logging.Logger getLogger()
Get logger for this instance. By default all log messages belong to this class. Subclasses can override this behavior.
Overrides:
getLogger in interface AbstractConnectionPool
Returns:
instance of Logger.

getLoginTimeout

public int getLoginTimeout()
Get login timeout.
Overrides:
getLoginTimeout in interface BasicAbstractConnectionPool
Returns:
value set in setLoginTimeout(int) method or 0.

getPoolName

protected String getPoolName()
Get name of this connection pool.
Overrides:
getPoolName in interface AbstractConnectionPool
Returns:
name of the pool, equal to the JDBC URL value.

getPooledConnection

public PooledConnection getPooledConnection()
            throws SQLException
Get pooled connection. This method will block until there will be free connection to return.
Overrides:
getPooledConnection in interface BasicAbstractConnectionPool
Returns:
instance of PooledConnection.

getPooledConnection

public PooledConnection getPooledConnection(String user,
                                            String password)
            throws SQLException
Get pooled connection for the specified user name and password.
Overrides:
getPooledConnection in interface BasicAbstractConnectionPool
Parameters:
user - user name.
password - password corresponding to specified user name.
Returns:
instance of PooledConnection for the specified credentials.

getPooledConnection

protected PooledObject getPooledConnection(org.firebirdsql.pool.PooledConnectionQueue queue)
            throws SQLException
Get pooled connection from the pooled queue.
Overrides:
getPooledConnection in interface AbstractConnectionPool

getProperties

public Properties getProperties()

getProperty

public String getProperty(String name)

getTotalSize

public int getTotalSize()
            throws SQLException
Get total size of physical connections opened to the database.
Overrides:
getTotalSize in interface AbstractConnectionPool
Returns:
total number of opened connections to the database.

getTransactionIsolationLevel

public int getTransactionIsolationLevel()

getWorkingSize

public int getWorkingSize()
            throws SQLException
Get number of connections that are in use.
Overrides:
getWorkingSize in interface AbstractConnectionPool
Returns:
number of working connections.

physicalConnectionClosed

public void physicalConnectionClosed(ConnectionEvent connectionEvent)
Notify about physical connection being closed.
Specified by:
physicalConnectionClosed in interface PooledConnectionEventListener
Parameters:
connectionEvent - instance of ConnectionEvent.

physicalConnectionDeallocated

public void physicalConnectionDeallocated(ConnectionEvent connectionEvent)
Notify about the deallocation of the physical connection.
Specified by:
physicalConnectionDeallocated in interface PooledConnectionEventListener
Parameters:
connectionEvent - instance of ConnectionEvent.

processObjectInstance

protected Object processObjectInstance(AbstractDriverConnectionPoolDataSource ds,
                                       Object obj)
            throws Exception

setDriverClassName

public void setDriverClassName(String driverClassName)

setIsolation

public void setIsolation(String isolation)
            throws SQLException

setJdbcUrl

public void setJdbcUrl(String jdbcUrl)

setLogWriter

public void setLogWriter(PrintWriter out)
Overrides:
setLogWriter in interface BasicAbstractConnectionPool

setLoginTimeout

public void setLoginTimeout(int seconds)
Set login timeout for new connection. Currently ignored.
Overrides:
setLoginTimeout in interface BasicAbstractConnectionPool
Parameters:
seconds - how long pool should wait until new connection is granted.

setProperties

public void setProperties(Properties properties)
Set JDBC properties that will be passed when opening a connection.
Parameters:
properties - instance of Properties containing properties of a connection to open.

setProperty

public void setProperty(String name,
                        String value)

setTransactionIsolationLevel

public void setTransactionIsolationLevel(int transactionIsolation)

Copyright B) 2001 David Jencks and other authors. All rights reserved.