Class DatasourceConfiguration
java.lang.Object
io.micronaut.configuration.jdbc.ucp.DatasourceConfiguration
- All Implemented Interfaces:
BasicJdbcConfiguration
@EachProperty(value="datasources",
primary="default")
@Context
public class DatasourceConfiguration
extends Object
implements BasicJdbcConfiguration
Allows the configuration of UCP JDBC data sources. All properties on
PoolDataSourceImpl
are available to be configured.
If the url, driver class, validation sql query, username, or password are missing, sensible defaults will be provided when possible. If no configuration beyond the datasource name is provided, an in memory datasource will be configured based on the available drivers on the classpath.
- Since:
- 2.0.1
- Author:
- toddsharp
-
Field Summary
Fields inherited from interface io.micronaut.jdbc.BasicJdbcConfiguration
PREFIX
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetName()
oracle.ucp.jdbc.PoolDataSource
getUrl()
void
Configures the missing properties of the data source from the calculated settings.void
setDataSourceProperties
(Map<String, ?> dsProperties) Sets the datasource properties.void
setDriverClassName
(String driverClassName) void
void
setPassword
(String password) void
void
setUsername
(String username) void
setValidationQuery
(String validationQuery)
-
Constructor Details
-
DatasourceConfiguration
Constructor.- Parameters:
name
- name that comes from properties- Throws:
SQLException
-
-
Method Details
-
getPoolDataSource
public oracle.ucp.jdbc.PoolDataSource getPoolDataSource()- Returns:
- the pool data source
- Since:
- 4.1
-
getName
- Specified by:
getName
in interfaceBasicJdbcConfiguration
- Returns:
- A user provided name to identify the datasource
-
setName
- Parameters:
name
- the name of the datasource- Throws:
SQLException
- an sql exception
-
getDriverClassName
- Specified by:
getDriverClassName
in interfaceBasicJdbcConfiguration
- Returns:
- The driver class name to be used by the data source
-
setDriverClassName
- Specified by:
setDriverClassName
in interfaceBasicJdbcConfiguration
- Parameters:
driverClassName
- Sets the driver class name
-
getConfiguredDriverClassName
- Specified by:
getConfiguredDriverClassName
in interfaceBasicJdbcConfiguration
- Returns:
- The driver class name supplied via configuration
-
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
- Specified by:
setUrl
in interfaceBasicJdbcConfiguration
- Parameters:
url
- Sets the url
-
getUsername
- Specified by:
getUsername
in interfaceBasicJdbcConfiguration
- Returns:
- The username to be used by the data source
-
setUsername
- Specified by:
setUsername
in interfaceBasicJdbcConfiguration
- Parameters:
username
- the username
-
getConfiguredUsername
- Specified by:
getConfiguredUsername
in interfaceBasicJdbcConfiguration
- Returns:
- The username supplied via configuration
-
getPassword
- Specified by:
getPassword
in interfaceBasicJdbcConfiguration
- Returns:
- The password to be used by the data source
-
setPassword
- Specified by:
setPassword
in interfaceBasicJdbcConfiguration
- Parameters:
password
- Sets the password
-
getConfiguredPassword
- Specified by:
getConfiguredPassword
in interfaceBasicJdbcConfiguration
- Returns:
- The password supplied via configuration
-
getValidationQuery
- Specified by:
getValidationQuery
in interfaceBasicJdbcConfiguration
- Returns:
- The validation query to be used by the data source
-
setValidationQuery
-
setDataSourceProperties
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
-
initialize
@PostConstruct public void initialize()Configures the missing properties of the data source from the calculated settings.- Since:
- 4.0.2
-