public final class PoolManager extends Object
| Constructor and Description |
|---|
PoolManager() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addListener(Connection dbc,
IDatabaseEventListener el)
Add an event listener to the specified connection.
|
void |
addMessageListener(IPoolMessageHandler pmh) |
void |
clearThreadConnections() |
ConnectionPool |
definePool(File poolfile,
String id)
This defines a pool, taking it's config from a properties file.
|
ConnectionPool |
definePool(PoolConfigSource cs,
String id)
Defines the pool with the specified ID from the ConfigSource passed.
|
ConnectionPool |
definePool(String id)
This defines a pool using the default poolfile ".dbpool.properties" stored
in the user's home directory.
|
ConnectionPool |
definePool(String id,
PoolConfig pc) |
ConnectionPool |
definePool(String id,
String driver,
String url,
String userid,
String password,
String driverpath) |
void |
destroyAll()
Destroy all current pools.
|
void |
destroyPool(String poolid) |
static PoolManager |
getInstance() |
ConnectionPool |
getPool(String id)
Finds the named pool.
|
int |
getPoolCount()
Return the #of pools currently defined.
|
static ConnectionPool |
getPoolFrom(DataSource ds) |
ConnectionPool[] |
getPoolList()
Return all currently defined pools.
|
List<ConnectionProxy> |
getThreadConnections() |
static DataSource |
getUnpooledFrom(DataSource ds)
Try to get the unpooled datasource associated with this datasource, if that
datasource comes from the pool manager.
|
ConnectionPool |
initializePool(File poolfile,
String id)
This combines defining and initializing a pool, taking it's config from
a properties file.
|
ConnectionPool |
initializePool(PoolConfigSource cs,
String id)
This combines defining and initializing a pool.
|
ConnectionPool |
initializePool(String id)
Initializes the pool defined by ID by pre-allocating the first min
connections from it.
|
boolean |
isCheckCloseConnections() |
boolean |
isCollectStatistics() |
void |
logUnexpected(Exception t,
String s) |
void |
logUnexpected(String s) |
void |
panic(String shortdesc,
String body) |
static void |
removeListener(Connection dbc,
IDatabaseEventListener el)
Remove an event listener that was added before from the specified connection.
|
void |
removeMessageListener(IPoolMessageHandler pmh) |
void |
sendLogUnexpected(Exception t,
String s) |
void |
sendPanic(String shortdesc,
String body) |
void |
setCheckCloseConnections(boolean checkCloseConnections) |
void |
setCollectStatistics(boolean on) |
static void |
setLongLiving(Connection dbc)
Mark connection long living, for those connections which need
to be opened for a long time (hanging connection check will skip
this connection).
|
boolean |
startCollecting(String key,
IStatisticsListener collector)
Registers a statistics collection listener for the current thread.
|
protected void |
startExpiredConnectionScanner()
Starts the scanner if database locking security is requested.
|
IStatisticsListener |
stopCollecting(String key)
Returns the collector with the specified key.
|
public static PoolManager getInstance()
public void logUnexpected(String s)
public void addMessageListener(IPoolMessageHandler pmh)
public void removeMessageListener(IPoolMessageHandler pmh)
public int getPoolCount()
@Nonnull public ConnectionPool getPool(@Nonnull String id) throws SQLException
SQLExceptionpublic ConnectionPool[] getPoolList()
public ConnectionPool definePool(String id, PoolConfig pc) throws SQLException
SQLExceptionpublic ConnectionPool definePool(PoolConfigSource cs, String id) throws SQLException
SQLExceptionpublic ConnectionPool definePool(String id, String driver, String url, String userid, String password, String driverpath) throws SQLException
SQLExceptionpublic ConnectionPool definePool(File poolfile, String id) throws Exception
poolfile - id - Exceptionpublic ConnectionPool definePool(String id) throws Exception
id - Exceptionpublic ConnectionPool initializePool(String id) throws Exception
Exceptionpublic ConnectionPool initializePool(PoolConfigSource cs, String id) throws SQLException
cs - The configsource to take definitions fromid - The ID of the pool to define.ExceptionSQLExceptionpublic ConnectionPool initializePool(File poolfile, String id) throws Exception
poolfile - id - Exceptionpublic void destroyAll()
public void destroyPool(String poolid) throws SQLException
SQLExceptionprotected void startExpiredConnectionScanner()
public boolean startCollecting(String key, IStatisticsListener collector)
public IStatisticsListener stopCollecting(String key)
key - public void setCollectStatistics(boolean on)
public boolean isCollectStatistics()
public static void addListener(@Nonnull Connection dbc, @Nonnull IDatabaseEventListener el)
dbc - el - public static void removeListener(@Nonnull Connection dbc, @Nonnull IDatabaseEventListener el)
dbc - el - public boolean isCheckCloseConnections()
public void setCheckCloseConnections(boolean checkCloseConnections)
public List<ConnectionProxy> getThreadConnections()
public void clearThreadConnections()
public static void setLongLiving(@Nonnull Connection dbc) throws SQLException
dbc - SQLException@Nullable public static ConnectionPool getPoolFrom(@Nonnull DataSource ds)
@Nonnull public static DataSource getUnpooledFrom(@Nonnull DataSource ds)
ds - Copyright © 2017 etc.to. All rights reserved.