Class DatasourceConfiguration
java.lang.Object
com.zaxxer.hikari.HikariConfig
io.micronaut.configuration.jdbc.hikari.DatasourceConfiguration
- All Implemented Interfaces:
com.zaxxer.hikari.HikariConfigMXBean
,BasicJdbcConfiguration
@EachProperty(value="datasources",
primary="default")
public class DatasourceConfiguration
extends com.zaxxer.hikari.HikariConfig
implements BasicJdbcConfiguration
Allows the configuration of Hikari JDBC data sources. All properties on
HikariConfig
are available to be configured.
If the url, driver class, username, or password are missing, sensible defaults
will be provided when possible. If no configuration beyond the datasource name
is provided, an in memory datastore will be configured based on the available
drivers on the classpath.- Since:
- 1.0
- Author:
- James Kleeh
-
Field Summary
Fields inherited from interface io.micronaut.jdbc.BasicJdbcConfiguration
PREFIX
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGet Jndi name.getName()
getUrl()
boolean
void
setAutomaticValidationQuery
(boolean automaticValidationQuery) Set to true if the validation query should be set with an appropriate default value if not set manually.void
setDataSourceProperties
(Map<String, ?> dsProperties) Sets the data source properties.void
setJndiName
(String jndiName) Setter.void
Setter.void
setValidationQuery
(String validationQuery) Setter.Methods inherited from class com.zaxxer.hikari.HikariConfig
addDataSourceProperty, addHealthCheckProperty, copyStateTo, getCatalog, getConnectionInitSql, getConnectionTestQuery, getConnectionTimeout, getCredentials, getDataSource, getDataSourceClassName, getDataSourceJNDI, getDataSourceProperties, getExceptionOverride, getExceptionOverrideClassName, getHealthCheckProperties, getHealthCheckRegistry, getIdleTimeout, getInitializationFailTimeout, getJdbcUrl, getKeepaliveTime, getLeakDetectionThreshold, getMaximumPoolSize, getMaxLifetime, getMetricRegistry, getMetricsTrackerFactory, getMinimumIdle, getPoolName, getScheduledExecutor, getSchema, getThreadFactory, getTransactionIsolation, getValidationTimeout, isAllowPoolSuspension, isAutoCommit, isIsolateInternalQueries, isReadOnly, isRegisterMbeans, setAllowPoolSuspension, setAutoCommit, setCatalog, setConnectionInitSql, setConnectionTestQuery, setConnectionTimeout, setCredentials, setDataSource, setDataSourceClassName, setDataSourceJNDI, setDataSourceProperties, setDriverClassName, setExceptionOverride, setExceptionOverrideClassName, setHealthCheckProperties, setHealthCheckRegistry, setIdleTimeout, setInitializationFailTimeout, setIsolateInternalQueries, setJdbcUrl, setKeepaliveTime, setLeakDetectionThreshold, setMaximumPoolSize, setMaxLifetime, setMetricRegistry, setMetricsTrackerFactory, setMinimumIdle, setPassword, setPoolName, setReadOnly, setRegisterMbeans, setScheduledExecutor, setSchema, setThreadFactory, setTransactionIsolation, setUsername, setValidationTimeout, validate
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.jdbc.BasicJdbcConfiguration
setDriverClassName, setPassword, setUsername
-
Constructor Details
-
DatasourceConfiguration
Constructor.- Parameters:
name
- name that comes from properties
-
-
Method Details
-
getName
- Specified by:
getName
in interfaceBasicJdbcConfiguration
- Returns:
- A user provided name to identify the datasource
-
getConfiguredUrl
- Specified by:
getConfiguredUrl
in interfaceBasicJdbcConfiguration
- Returns:
- The URL supplied via configuration
-
getUrl
- Specified by:
getUrl
in interfaceBasicJdbcConfiguration
- Returns:
- The URL to be used by the data source
-
setUrl
Setter.- Specified by:
setUrl
in interfaceBasicJdbcConfiguration
- Parameters:
url
- url of connection
-
getConfiguredDriverClassName
- Specified by:
getConfiguredDriverClassName
in interfaceBasicJdbcConfiguration
- Returns:
- The driver class name supplied via configuration
-
getDriverClassName
- Specified by:
getDriverClassName
in interfaceBasicJdbcConfiguration
- Overrides:
getDriverClassName
in classcom.zaxxer.hikari.HikariConfig
- Returns:
- The driver class name to be used by the data source
-
getConfiguredUsername
- Specified by:
getConfiguredUsername
in interfaceBasicJdbcConfiguration
- Returns:
- The username supplied via configuration
-
getUsername
- Specified by:
getUsername
in interfaceBasicJdbcConfiguration
- Overrides:
getUsername
in classcom.zaxxer.hikari.HikariConfig
- Returns:
- The username to be used by the data source
-
getConfiguredPassword
- Specified by:
getConfiguredPassword
in interfaceBasicJdbcConfiguration
- Returns:
- The password supplied via configuration
-
getPassword
- Specified by:
getPassword
in interfaceBasicJdbcConfiguration
- Overrides:
getPassword
in classcom.zaxxer.hikari.HikariConfig
- Returns:
- The password to be used by the data source
-
getConfiguredValidationQuery
- Specified by:
getConfiguredValidationQuery
in interfaceBasicJdbcConfiguration
- Returns:
- The validation query supplied via configuration
-
getValidationQuery
- Specified by:
getValidationQuery
in interfaceBasicJdbcConfiguration
- Returns:
- The validation query to be used by the data source
-
setValidationQuery
Setter.- Parameters:
validationQuery
- string of query
-
getJndiName
Get Jndi name.- Returns:
- jndiName
-
setJndiName
Setter.- Parameters:
jndiName
- jndi name
-
setDataSourceProperties
public void setDataSourceProperties(@MapFormat(transformation=FLAT,keyFormat=RAW) Map<String, ?> dsProperties) Sets the data source properties.- Specified by:
setDataSourceProperties
in interfaceBasicJdbcConfiguration
- Parameters:
dsProperties
- The datasource properties
-
isAutomaticValidationQuery
public boolean isAutomaticValidationQuery()- Returns:
- True if the validation query should be set automatically
-
setAutomaticValidationQuery
public void setAutomaticValidationQuery(boolean automaticValidationQuery) Set to true if the validation query should be set with an appropriate default value if not set manually.- Parameters:
automaticValidationQuery
- Whether to auto set the validation query
-