public class HikariDataSource extends HikariConfig implements javax.sql.DataSource, java.io.Closeable
Constructor and Description |
---|
HikariDataSource()
Default constructor.
|
HikariDataSource(HikariConfig configuration)
Construct a HikariDataSource with the specified configuration.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Shutdown the DataSource and its associated pool.
|
void |
evictConnection(java.sql.Connection connection)
Evict a connection from the pool.
|
java.sql.Connection |
getConnection() |
java.sql.Connection |
getConnection(java.lang.String username,
java.lang.String password) |
HikariConfigMXBean |
getHikariConfigMXBean()
Get the
HikariConfigMXBean for this HikariDataSource instance. |
HikariPoolMXBean |
getHikariPoolMXBean()
Get the
HikariPoolMXBean for this HikariDataSource instance. |
int |
getLoginTimeout() |
java.io.PrintWriter |
getLogWriter() |
java.util.logging.Logger |
getParentLogger() |
boolean |
isClosed()
Determine whether the HikariDataSource has been closed.
|
boolean |
isRunning()
Returns
true if the pool as been started and is not suspended or shutdown. |
boolean |
isWrapperFor(java.lang.Class<?> iface) |
void |
setHealthCheckRegistry(java.lang.Object healthCheckRegistry)
Set the HealthCheckRegistry that will be used for registration of health checks by HikariCP.
|
void |
setLoginTimeout(int seconds) |
void |
setLogWriter(java.io.PrintWriter out) |
void |
setMetricRegistry(java.lang.Object metricRegistry)
Set a MetricRegistry instance to use for registration of metrics used by HikariCP.
|
void |
setMetricsTrackerFactory(MetricsTrackerFactory metricsTrackerFactory) |
java.lang.String |
toString() |
<T> T |
unwrap(java.lang.Class<T> iface) |
addDataSourceProperty, addHealthCheckProperty, copyStateTo, getCatalog, getConnectionInitSql, getConnectionTestQuery, getConnectionTimeout, getDataSource, getDataSourceClassName, getDataSourceJNDI, getDataSourceProperties, getDriverClassName, getHealthCheckProperties, getHealthCheckRegistry, getIdleTimeout, getInitializationFailTimeout, getJdbcUrl, getLeakDetectionThreshold, getMaximumPoolSize, getMaxLifetime, getMetricRegistry, getMetricsTrackerFactory, getMinimumIdle, getPassword, getPoolName, getScheduledExecutor, getSchema, getThreadFactory, getTransactionIsolation, getUsername, getValidationTimeout, isAllowPoolSuspension, isAutoCommit, isIsolateInternalQueries, isReadOnly, isRegisterMbeans, setAllowPoolSuspension, setAutoCommit, setCatalog, setConnectionInitSql, setConnectionTestQuery, setConnectionTimeout, setDataSource, setDataSourceClassName, setDataSourceJNDI, setDataSourceProperties, setDriverClassName, setHealthCheckProperties, setIdleTimeout, setInitializationFailTimeout, setIsolateInternalQueries, setJdbcUrl, setLeakDetectionThreshold, setMaximumPoolSize, setMaxLifetime, setMinimumIdle, setPassword, setPoolName, setReadOnly, setRegisterMbeans, setScheduledExecutor, setSchema, setThreadFactory, setTransactionIsolation, setUsername, setValidationTimeout, validate
public HikariDataSource()
HikariDataSource(HikariConfig)
will
result in getConnection()
performance that is slightly lower
due to lazy initialization checks.
The first call to getConnection()
starts the pool. Once the pool
is started, the configuration is "sealed" and no further configuration
changes are possible -- except via HikariConfigMXBean
methods.public HikariDataSource(HikariConfig configuration)
HikariConfig
is copied and the pool is started by invoking this
constructor.
The HikariConfig
can be modified without affecting the HikariDataSource
and used to initialize another HikariDataSource instance.configuration
- a HikariConfig instancepublic java.sql.Connection getConnection() throws java.sql.SQLException
getConnection
in interface javax.sql.DataSource
java.sql.SQLException
public java.sql.Connection getConnection(java.lang.String username, java.lang.String password) throws java.sql.SQLException
getConnection
in interface javax.sql.DataSource
java.sql.SQLException
public java.io.PrintWriter getLogWriter() throws java.sql.SQLException
getLogWriter
in interface javax.sql.CommonDataSource
java.sql.SQLException
public void setLogWriter(java.io.PrintWriter out) throws java.sql.SQLException
setLogWriter
in interface javax.sql.CommonDataSource
java.sql.SQLException
public void setLoginTimeout(int seconds) throws java.sql.SQLException
setLoginTimeout
in interface javax.sql.CommonDataSource
java.sql.SQLException
public int getLoginTimeout() throws java.sql.SQLException
getLoginTimeout
in interface javax.sql.CommonDataSource
java.sql.SQLException
public java.util.logging.Logger getParentLogger() throws java.sql.SQLFeatureNotSupportedException
getParentLogger
in interface javax.sql.CommonDataSource
java.sql.SQLFeatureNotSupportedException
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException
unwrap
in interface java.sql.Wrapper
java.sql.SQLException
public boolean isWrapperFor(java.lang.Class<?> iface) throws java.sql.SQLException
isWrapperFor
in interface java.sql.Wrapper
java.sql.SQLException
public void setMetricRegistry(java.lang.Object metricRegistry)
setMetricRegistry
in class HikariConfig
metricRegistry
- the MetricRegistry instance to usepublic void setMetricsTrackerFactory(MetricsTrackerFactory metricsTrackerFactory)
setMetricsTrackerFactory
in class HikariConfig
public void setHealthCheckRegistry(java.lang.Object healthCheckRegistry)
null
.setHealthCheckRegistry
in class HikariConfig
healthCheckRegistry
- the HealthCheckRegistry to be usedpublic boolean isRunning()
true
if the pool as been started and is not suspended or shutdown.true
if the pool as been started and is not suspended or shutdown.public HikariPoolMXBean getHikariPoolMXBean()
HikariPoolMXBean
for this HikariDataSource instance. If this method is called on
a HikariDataSource
that has been constructed without a HikariConfig
instance,
and before an initial call to #getConnection()
, the return value will be null
.HikariPoolMXBean
instance, or null
.public HikariConfigMXBean getHikariConfigMXBean()
HikariConfigMXBean
for this HikariDataSource instance.HikariConfigMXBean
instance.public void evictConnection(java.sql.Connection connection)
connection
- the connection to evict from the poolpublic void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
public boolean isClosed()
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2020 Zaxxer.com. All Rights Reserved.