public final class ConnectionFactory extends Object
DataSourceFactory factory| Modifier and Type | Method and Description |
|---|---|
static Connection |
getConnection(ConnectionProperties poolSpec)
Return a Connection instance from a pool that manages JDBC driver based connections.
|
static Connection |
getConnection(String jndiName)
Return a Connection instance for a JNDI managed JDBC connection.
|
static void |
reset()
Resets the internal state of the
DataSourceFactory that manages the data source pools exposed by this
factory. |
public static Connection getConnection(String jndiName) throws FactoryException
jndiName - The JNDI connection nameFactoryException - When the connection cannot be retrieved from JNDINullPointerException - When jndiName is nullIllegalArgumentException - When jndiName is emptypublic static Connection getConnection(ConnectionProperties poolSpec) throws FactoryException
The driver-based connection are managed in a connection pool. The pool is created using the provided properties for both the connection and the pool spec. Once the pool has been created, it is cached (based on URL and username), and can no longer be changed. Subsequent calls to this method will return a connection from the cached pool, and changes in the pool spec (e.g. changes to the size of the pool) will be ignored.
poolSpec - A connection pool spec that has the driver and url configured as non-empty stringsFactoryException - When the connection cannot be retrieved from the pool, or the pool cannot be
createdNullPointerException - When the poolSpec, poolSpec.getDriver(), or
poolSpec.getUrl() are nullIllegalArgumentException - When poolSpec.getDriver() or poolSpec.getUrl() are emptypublic static void reset()
DataSourceFactory that manages the data source pools exposed by this
factory.
This method does not release any resources that have been borrowed from the connection pools managed by this factory. To avoid resource leaks, you must close / return all connections to their pools before calling this method.
Copyright © 2014–2016 Michael Beiter