public class DBConnectionPool extends Object
Modifier and Type | Class and Description |
---|---|
protected class |
DBConnectionPool.DBConnectionReaper
Database Connection Reaper Thread Class
|
Modifier and Type | Field and Description |
---|---|
static int |
DefaultMaxSize |
static int |
DefaultMinSize |
static int |
MaximumConnections |
static int |
MinimumConnections |
static long |
PermanentLease |
Constructor and Description |
---|
DBConnectionPool(String driver,
String dsn,
String user,
String pwd)
Class constructor
|
DBConnectionPool(String driver,
String dsn,
String user,
String pwd,
int initConns,
int maxConns)
Class constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addConnectionPoolListener(DBConnectionPoolListener l)
Add a database connection pool listener
|
void |
closePool()
Close the connection pool
|
protected Connection |
createConnection()
Create a new database connection
|
int |
getAllocatedConnections()
Get the in use connection count
|
int |
getAvailableConnections()
Get the available connection count
|
Connection |
getConnection()
Get a connection from the pool
|
Connection |
getConnection(long expireTime)
Get a connection from the pool with the specified lease time.
|
String |
getDriver()
Get the JDBC driver details
|
String |
getDSN()
Get the connection details
|
long |
getLeaseTime()
Get the connection lease time, in milliseconds
|
int |
getMaximumPoolSize()
Get the maximum pool size
|
int |
getMinimumPoolSize()
Get the minimum pool size
|
String |
getPassword()
Get the password
|
String |
getUserName()
Get the user name
|
boolean |
hasConnectionPoolListener()
Check if there is a connection pool listener
|
boolean |
isOnline()
Check if the connection pool is online
|
protected void |
notifyConnectionPoolState()
Notify the connection pool listener of an online/offline state change
|
void |
releaseConnection(Connection conn)
Release a connection back to the free pool
|
DBConnectionPoolListener |
removeConnectionPoolListener()
Remove a database connection pool listener
|
void |
renewLease(Connection conn)
Renew a lease on a connection for the default lease time
|
void |
renewLease(Connection conn,
long expireTime)
Renew a lease on a connection to hold onto the connection for longer
|
void |
setDefaultLeaseTime(long leaseTime)
Set the default connection lease time
|
void |
setOnlineCheckInterval(int interval)
Set the online check interval, in seconds
|
void |
setPoolSize(int initSize,
int maxSize)
Set the connection pool initial and maximum sizes
|
public static final long PermanentLease
public static final int MinimumConnections
public static final int MaximumConnections
public static final int DefaultMinSize
public static final int DefaultMaxSize
public DBConnectionPool(String driver, String dsn, String user, String pwd) throws Exception
driver
- Stringdsn
- Stringuser
- Stringpwd
- StringException
public final String getDriver()
public final String getDSN()
public final String getUserName()
public final String getPassword()
public final int getMinimumPoolSize()
public final int getMaximumPoolSize()
public final long getLeaseTime()
public final int getAvailableConnections()
public final int getAllocatedConnections()
public final Connection getConnection()
public final boolean isOnline()
public final Connection getConnection(long expireTime)
expireTime
- longpublic final void releaseConnection(Connection conn)
conn
- Connectionpublic final void renewLease(Connection conn)
conn
- Connectionpublic final void renewLease(Connection conn, long expireTime)
conn
- ConnectionexpireTime
- longpublic final void closePool()
public final void setPoolSize(int initSize, int maxSize)
initSize
- intmaxSize
- intpublic final void setDefaultLeaseTime(long leaseTime)
leaseTime
- longpublic final void setOnlineCheckInterval(int interval)
interval
- intpublic final boolean hasConnectionPoolListener()
public final void addConnectionPoolListener(DBConnectionPoolListener l)
l
- DBConnectionPoolListenerpublic final DBConnectionPoolListener removeConnectionPoolListener()
protected final Connection createConnection() throws SQLException
SQLException
protected final void notifyConnectionPoolState()
Copyright © 2005–2018 Alfresco Software. All rights reserved.