Class DatasourceConfiguration
java.lang.Object
org.apache.commons.dbcp2.BasicDataSource
io.micronaut.configuration.jdbc.dbcp.DatasourceConfiguration
- All Implemented Interfaces:
BasicJdbcConfiguration
,AutoCloseable
,Wrapper
,MBeanRegistration
,CommonDataSource
,DataSource
,org.apache.commons.dbcp2.BasicDataSourceMXBean
,org.apache.commons.dbcp2.DataSourceMXBean
@Context
@EachProperty(value="datasources",
primary="default")
public class DatasourceConfiguration
extends org.apache.commons.dbcp2.BasicDataSource
implements BasicJdbcConfiguration
Allows the configuration of Apache DBCP JDBC data sources. All properties on
BasicDataSource
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetName()
Get the name of the bean.getUrl()
void
setConnectionPropertiesString
(String connectionProperties) A helper method to allow setting the connectionProperties via a single String.void
setDataSourceProperties
(Map<String, ?> dsProperties) Sets the datasource properties.Methods inherited from class org.apache.commons.dbcp2.BasicDataSource
addConnectionProperty, close, createConnectionFactory, createConnectionPool, createDataSource, createDataSourceInstance, createObjectPool, createPoolableConnectionFactory, evict, getAbandonedLogWriter, getAbandonedUsageTracking, getAutoCommitOnReturn, getCacheState, getConnection, getConnection, getConnectionFactoryClassName, getConnectionInitSqls, getConnectionInitSqlsAsArray, getConnectionPool, getDefaultAutoCommit, getDefaultCatalog, getDefaultQueryTimeout, getDefaultQueryTimeoutDuration, getDefaultReadOnly, getDefaultSchema, getDefaultTransactionIsolation, getDisconnectionSqlCodes, getDisconnectionSqlCodesAsArray, getDriver, getDriverClassLoader, getDurationBetweenEvictionRuns, getEnableAutoCommitOnReturn, getEvictionPolicyClassName, getFastFailValidation, getInitialSize, getJmxName, getLifo, getLogAbandoned, getLogExpiredConnections, getLoginTimeout, getLogWriter, getMaxConnDuration, getMaxConnLifetimeMillis, getMaxIdle, getMaxOpenPreparedStatements, getMaxTotal, getMaxWaitDuration, getMaxWaitMillis, getMinEvictableIdleDuration, getMinEvictableIdleTimeMillis, getMinIdle, getNumActive, getNumIdle, getNumTestsPerEvictionRun, getParentLogger, getRegisteredJmxName, getRemoveAbandonedOnBorrow, getRemoveAbandonedOnMaintenance, getRemoveAbandonedTimeout, getRemoveAbandonedTimeoutDuration, getRollbackOnReturn, getSoftMinEvictableIdleDuration, getSoftMinEvictableIdleTimeMillis, getTestOnBorrow, getTestOnCreate, getTestOnReturn, getTestWhileIdle, getTimeBetweenEvictionRunsMillis, getValidationQueryTimeout, getValidationQueryTimeoutDuration, invalidateConnection, isAccessToUnderlyingConnectionAllowed, isClearStatementPoolOnReturn, isClosed, isPoolPreparedStatements, isWrapperFor, log, log, postDeregister, postRegister, preDeregister, preRegister, removeConnectionProperty, restart, setAbandonedLogWriter, setAbandonedUsageTracking, setAccessToUnderlyingConnectionAllowed, setAutoCommitOnReturn, setCacheState, setClearStatementPoolOnReturn, setConnectionFactoryClassName, setConnectionInitSqls, setConnectionProperties, setDefaultAutoCommit, setDefaultCatalog, setDefaultQueryTimeout, setDefaultQueryTimeout, setDefaultReadOnly, setDefaultSchema, setDefaultTransactionIsolation, setDisconnectionSqlCodes, setDriver, setDriverClassLoader, setDriverClassName, setDurationBetweenEvictionRuns, setEnableAutoCommitOnReturn, setEvictionPolicyClassName, setFastFailValidation, setInitialSize, setJmxName, setLifo, setLogAbandoned, setLogExpiredConnections, setLoginTimeout, setLogWriter, setMaxConn, setMaxConnLifetimeMillis, setMaxIdle, setMaxOpenPreparedStatements, setMaxTotal, setMaxWait, setMaxWaitMillis, setMinEvictableIdle, setMinEvictableIdleTimeMillis, setMinIdle, setNumTestsPerEvictionRun, setPassword, setPoolPreparedStatements, setRegisterConnectionMBean, setRemoveAbandonedOnBorrow, setRemoveAbandonedOnMaintenance, setRemoveAbandonedTimeout, setRemoveAbandonedTimeout, setRollbackOnReturn, setSoftMinEvictableIdle, setSoftMinEvictableIdleTimeMillis, setTestOnBorrow, setTestOnCreate, setTestOnReturn, setTestWhileIdle, setTimeBetweenEvictionRunsMillis, setUrl, setUsername, setValidationQuery, setValidationQueryTimeout, setValidationQueryTimeout, start, startPoolMaintenance, unwrap, validateConnectionFactory
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, setUrl, setUsername
Methods inherited from interface javax.sql.CommonDataSource
createShardingKeyBuilder
Methods inherited from interface javax.sql.DataSource
createConnectionBuilder
Methods inherited from interface org.apache.commons.dbcp2.DataSourceMXBean
getUserName
-
Constructor Details
-
DatasourceConfiguration
Constructor.- Parameters:
name
- name configured from properties
-
-
Method Details
-
getName
Get the name of the bean.- Specified by:
getName
in interfaceBasicJdbcConfiguration
- Returns:
- name
-
getDriverClassName
- Specified by:
getDriverClassName
in interfaceBasicJdbcConfiguration
- Specified by:
getDriverClassName
in interfaceorg.apache.commons.dbcp2.DataSourceMXBean
- Overrides:
getDriverClassName
in classorg.apache.commons.dbcp2.BasicDataSource
- Returns:
- The driver class name to be used by the data source
-
getConfiguredDriverClassName
- Specified by:
getConfiguredDriverClassName
in interfaceBasicJdbcConfiguration
- Returns:
- The driver class name supplied via configuration
-
getUrl
- Specified by:
getUrl
in interfaceBasicJdbcConfiguration
- Specified by:
getUrl
in interfaceorg.apache.commons.dbcp2.DataSourceMXBean
- Overrides:
getUrl
in classorg.apache.commons.dbcp2.BasicDataSource
- Returns:
- The URL to be used by the data source
-
getConfiguredUrl
- Specified by:
getConfiguredUrl
in interfaceBasicJdbcConfiguration
- Returns:
- The URL supplied via configuration
-
getUsername
- Specified by:
getUsername
in interfaceBasicJdbcConfiguration
- Specified by:
getUsername
in interfaceorg.apache.commons.dbcp2.DataSourceMXBean
- Overrides:
getUsername
in classorg.apache.commons.dbcp2.BasicDataSource
- Returns:
- The username to be used by the data source
-
getConfiguredUsername
- Specified by:
getConfiguredUsername
in interfaceBasicJdbcConfiguration
- Returns:
- The username supplied via configuration
-
getPassword
- Specified by:
getPassword
in interfaceorg.apache.commons.dbcp2.BasicDataSourceMXBean
- Specified by:
getPassword
in interfaceBasicJdbcConfiguration
- Overrides:
getPassword
in classorg.apache.commons.dbcp2.BasicDataSource
- Returns:
- The password to be used by the data source
-
getConfiguredPassword
- Specified by:
getConfiguredPassword
in interfaceBasicJdbcConfiguration
- Returns:
- The password supplied via configuration
-
getValidationQuery
- Specified by:
getValidationQuery
in interfaceBasicJdbcConfiguration
- Specified by:
getValidationQuery
in interfaceorg.apache.commons.dbcp2.DataSourceMXBean
- Overrides:
getValidationQuery
in classorg.apache.commons.dbcp2.BasicDataSource
- Returns:
- The validation query to be used by the data source
-
setConnectionPropertiesString
public void setConnectionPropertiesString(@Property(name="datasources.*.connection-properties") String connectionProperties) A helper method to allow setting the connectionProperties via a single String.- Parameters:
connectionProperties
- The connection properties
-
setDataSourceProperties
public void setDataSourceProperties(@MapFormat(transformation=FLAT,keyFormat=RAW) Map<String, ?> dsProperties) Description copied from interface:BasicJdbcConfiguration
Sets the datasource properties.- Specified by:
setDataSourceProperties
in interfaceBasicJdbcConfiguration
- Parameters:
dsProperties
- The properties
-
getConfiguredValidationQuery
- Specified by:
getConfiguredValidationQuery
in interfaceBasicJdbcConfiguration
- Returns:
- The validation query supplied via configuration
-