|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.tentackle.db.DefaultDbPool
public class DefaultDbPool
An implementation of a database pool.
It allows min/max sizes, fixed increments and timeouts for unused instances.
The pool can be used with any ConnectionManager.
If used with the DefaultConnectionManager, each Db instance corresponds to a
physical JDBC-connection. If used with an MpxConnectionManager, the Db instances
map to virtual connections that will be attached temporarily during db-operations,
i.e. the AppDbObjectCache will retain its data across sessions
(if not closed due to idle timeout).
This is the preferred configuration in server applications with a lot of clients.
In order to clear the AppDbCache on db-close, you have to override the closeDb method.
| Constructor Summary | |
|---|---|
DefaultDbPool(String name,
ConnectionManager conMgr,
UserInfo userInfo,
int iniSize,
int incSize,
int minSize,
int maxSize,
int maxMinutes)
Creates a pool. |
|
DefaultDbPool(UserInfo ui)
Creates a pool useful for most servers. Using the default connection manager. |
|
| Method Summary | |
|---|---|
protected Db |
cloneDb(Db db)
Clones the masterDb to create a new Db instance. The method can be overridden if there is something to do after/before close. |
protected void |
closeDb(Db db)
Closes a db. The method can be overridden if there is something to do after/before close. |
Db |
getDb()
Gets a Db instance from the pool. |
int |
getMaxSize()
Gets the maximum poolsize. |
int |
getSize()
Gets the current number of Db instances. |
void |
putDb(Db db)
Returns a Db instance to the pool. |
void |
shutdown()
Closes all databases in the pool, cleans up and makes the pool unusable. |
String |
toString()
Gets the pool's name |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public DefaultDbPool(String name,
ConnectionManager conMgr,
UserInfo userInfo,
int iniSize,
int incSize,
int minSize,
int maxSize,
int maxMinutes)
name - the name of the poolconMgr - the connection manager to use for new Db instancesuserInfo - the userinfo for the created DbiniSize - the initial poolsizeincSize - the number of Db instances to enlarge the pool if all in useminSize - the minimum number of Db instances to keep in poolmaxSize - the maximum number of Db instances, 0 = unlimitedmaxMinutes - the timeout in minutes to close unused Db instances, 0 = never closepublic DefaultDbPool(UserInfo ui)
ui - the userinfo for the created Db| Method Detail |
|---|
public String toString()
toString in class Objectprotected void closeDb(Db db)
db - the Db instance to closeprotected Db cloneDb(Db db)
db - the master Db instance to clone
public void shutdown()
shutdown in interface DbPoolpublic int getMaxSize()
DbPool
getMaxSize in interface DbPoolpublic int getSize()
DbPool
getSize in interface DbPool
public Db getDb()
throws DbRuntimeException
DbPool
getDb in interface DbPoolDbRuntimeException - if pool is exhausted
public void putDb(Db db)
throws DbRuntimeException
DbPoolNotice: returning a Db to the pool more than once is allowed.
putDb in interface DbPooldb - the Db instance
DbRuntimeException - if the Db cannot be returned
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||