|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--anvil.database.ConnectionManager
Class providing interface for acquiring and releasing JDBC connections. Usage:
import java.sql.*;
import anvil.database.*;
ConnectionManager manager = ...;
PooledConnection connImpl = null;
Connection conn = null;
try {
connImpl = manager.acquire("njet");
conn = (Connection)connImpl.getConnection();
// do some work
} catch (NoConnectionPoolException e) {
// handle error
} catch (CannotReturnPooledConnectionException e) {
// handle error
} catch (SQLException e) {
// It is recommended that the connection is closed in case of SQLException.
// When the connection is closed the Connection.isClosed() method returns
// false and connection will be removed from the queue by the house-keeping
// thread after a short while.
if (conn!= null) {
conn.close();
}
} finally {
if (connImpl != null) {
connImpl.release();
}
}
| Constructor Summary | |
ConnectionManager()
Constructs connection manager. |
|
| Method Summary | |
PooledConnection |
acquire(java.lang.String connectionKey)
Acquires connection of given type. |
PooledConnection |
acquire(java.lang.String connectionKey,
int timeout)
Acquires connection of given type, overriding the connection reserve timeout. |
void |
addPool(ConnectionPool pool)
|
java.util.Iterator |
getAccessQueues()
Gets the iterator of ConnectionAccessQueues. |
boolean |
hasPool(java.lang.String pool)
|
void |
stop()
Shuts down the connection manager and all related classes. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public ConnectionManager()
| Method Detail |
public boolean hasPool(java.lang.String pool)
public void addPool(ConnectionPool pool)
public java.util.Iterator getAccessQueues()
ConnectionAccessQueues.
ConnectionAccessQueue
public PooledConnection acquire(java.lang.String connectionKey)
throws NoConnectionPoolException,
CannotReturnPooledConnectionException
connectionKey - Type of connection
ConnectionManager
NoConnectionPoolException - If connectionKey was null
or given pool has not been configured.
CannotReturnPooledConnectionException - If connection couldn't be
constructed, propably due the acquire timeout.
public PooledConnection acquire(java.lang.String connectionKey,
int timeout)
throws NoConnectionPoolException,
CannotReturnPooledConnectionException
connectionKey - Type of connectiontimeout - Timeout override in seconds (if > 0)
ConnectionManager
NoConnectionPoolException - If connectionKey was null
or given pool has not been configured.
CannotReturnPooledConnectionException - If connection couldn't be
constructed, propably due the acquire timeout.public void stop()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||