|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.armatiek.infofuze.pool.MiniConnectionPoolManager
public class MiniConnectionPoolManager
A simple standalone JDBC connection pool manager.
The public methods of this class are thread-safe.
Home page: www.source-code.biz
Author: Christian d'Heureuse, Inventec Informatik AG, Zurich, Switzerland
Multi-licensed: EPL/LGPL/MPL.
2007-06-21: Constructor with a timeout parameter added.
2008-05-03: Additional licenses added (EPL/MPL).
2009-06-26: Variable recycledConnections changed from Stack to Queue, so that
the unused connections are reused in a circular manner.
Thanks to Daniel Jurado for the tip.
2009-08-21: ArrayDeque (which was introduced with change 2009-06-26) replaced
by LinkedList, because ArrayDeque is only available since Java 1.6 and we want
to keep MiniConnectionPoolManager compatible with Java 1.5.
| Nested Class Summary | |
|---|---|
static class |
MiniConnectionPoolManager.TimeoutException
Thrown in getConnection() when no free connection becomes available within timeout seconds. |
| Constructor Summary | |
|---|---|
MiniConnectionPoolManager(javax.sql.ConnectionPoolDataSource dataSource,
int maxConnections)
Constructs a MiniConnectionPoolManager object with a timeout of 60 seconds. |
|
MiniConnectionPoolManager(javax.sql.ConnectionPoolDataSource dataSource,
int maxConnections,
int timeout)
Constructs a MiniConnectionPoolManager object. |
|
| Method Summary | |
|---|---|
void |
dispose()
Closes all unused pooled connections. |
int |
getActiveConnections()
Returns the number of active (open) connections of this pool. |
java.sql.Connection |
getConnection()
Retrieves a connection from the connection pool. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MiniConnectionPoolManager(javax.sql.ConnectionPoolDataSource dataSource,
int maxConnections)
dataSource - the data source for the connections.maxConnections - the maximum number of connections.
public MiniConnectionPoolManager(javax.sql.ConnectionPoolDataSource dataSource,
int maxConnections,
int timeout)
dataSource - the data source for the connections.maxConnections - the maximum number of connections.timeout - the maximum time in seconds to wait for a free connection.| Method Detail |
|---|
public void dispose()
throws java.sql.SQLException
java.sql.SQLException
public java.sql.Connection getConnection()
throws java.sql.SQLException
maxConnections connections are already in use, the method
waits until a connection becomes available or timeout seconds elapsed.
When the application is finished using the connection, it must close it
in order to return it to the pool.
MiniConnectionPoolManager.TimeoutException - when no connection becomes available within timeout seconds.
java.sql.SQLExceptionpublic int getActiveConnections()
Connection objects that have been
issued by getConnection() for which Connection.close()
has not yet been called.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||