...
Code Block | ||||
---|---|---|---|---|
| ||||
ConnectionPool connections = ConnectionPool.newCachedConnectionPool(host, port, username, password); |
Usage
Code Block | ||
---|---|---|
| ||
// assumes that the connection pool has been previously created
Concourse connection = null;
try{
connection = pool.request();
// do stuff
}
finally {
if(connection != null){
pool.release(connection);
}
} |
API Documentation
The API for fixed and cached connection pools is the same.
close
Code Block |
---|
void close() throws Exception |
Closes this resource, relinquishing any underlying resources. This method is invoked automatically on objects managed by the try-with-resources statement.
hasAvailableConnections
Code Block |
---|
boolean hasAvailableConnections() |
Return true if this pool has any available connections.
Returns
- true if a subsequent call the request() will not block
release
Code Block |
---|
void release(Concourse connection) |
Return a previously requested connection back to the pool.
Parameters
- connection
request
Code Block |
---|
Concourse request() |
Request a connection from the pool and possibly block until one is available.
Returns
- a connection to Concourse