public class HikariCpPoolingConnectionProvider extends Object implements PoolingConnectionProvider
A ConnectionProvider
implementation that creates its own
pool of connections.
This class uses HikariCP (https://brettwooldridge.github.io/HikariCP/) as the underlying pool implementation.
DBConnectionManager
,
ConnectionProvider
Modifier and Type | Field and Description |
---|---|
static String |
POOLING_PROVIDER_NAME
This pooling provider name.
|
DB_DRIVER, DB_MAX_CONNECTIONS, DB_PASSWORD, DB_URL, DB_USER, DB_VALIDATION_QUERY, DEFAULT_DB_MAX_CONNECTIONS, POOLING_PROVIDER, POOLING_PROVIDER_C3P0, POOLING_PROVIDER_HIKARICP
Constructor and Description |
---|
HikariCpPoolingConnectionProvider(Properties config)
Create a connection pool using the given properties.
|
HikariCpPoolingConnectionProvider(String dbDriver,
String dbURL,
String dbUser,
String dbPassword,
int maxConnections,
String dbValidationQuery) |
Modifier and Type | Method and Description |
---|---|
Connection |
getConnection() |
com.zaxxer.hikari.HikariDataSource |
getDataSource()
Get the HikariCP HikariDataSource created during initialization.
|
void |
initialize() |
void |
shutdown() |
public static final String POOLING_PROVIDER_NAME
public HikariCpPoolingConnectionProvider(String dbDriver, String dbURL, String dbUser, String dbPassword, int maxConnections, String dbValidationQuery) throws SQLException, SchedulerException
SQLException
SchedulerException
public HikariCpPoolingConnectionProvider(Properties config) throws SchedulerException, SQLException
The properties passed should contain:
PoolingConnectionProvider.DB_DRIVER
- The database driver class name
PoolingConnectionProvider.DB_URL
- The database URL
PoolingConnectionProvider.DB_USER
- The database user
PoolingConnectionProvider.DB_PASSWORD
- The database password
PoolingConnectionProvider.DB_MAX_CONNECTIONS
- The maximum # connections in the pool,
optional
PoolingConnectionProvider.DB_VALIDATION_QUERY
- The sql validation query, optional
config
- configuration propertiesSchedulerException
SQLException
public com.zaxxer.hikari.HikariDataSource getDataSource()
This can be used to set additional data source properties in a subclass's constructor.
getDataSource
in interface PoolingConnectionProvider
public Connection getConnection() throws SQLException
getConnection
in interface ConnectionProvider
SQLException
public void shutdown() throws SQLException
shutdown
in interface ConnectionProvider
SQLException
public void initialize() throws SQLException
initialize
in interface ConnectionProvider
SQLException
Copyright 2001-2019, Terracotta, Inc.