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
  • Constructor Details

    • DatasourceConfiguration

      public DatasourceConfiguration(@Parameter String name)
      Constructor.
      Parameters:
      name - name that comes from properties
  • Method Details

    • getName

      public String getName()
      Specified by:
      getName in interface BasicJdbcConfiguration
      Returns:
      A user provided name to identify the datasource
    • getConfiguredUrl

      public String getConfiguredUrl()
      Specified by:
      getConfiguredUrl in interface BasicJdbcConfiguration
      Returns:
      The URL supplied via configuration
    • getUrl

      public String getUrl()
      Specified by:
      getUrl in interface BasicJdbcConfiguration
      Returns:
      The URL to be used by the data source
    • setUrl

      public void setUrl(String url)
      Setter.
      Specified by:
      setUrl in interface BasicJdbcConfiguration
      Parameters:
      url - url of connection
    • getConfiguredDriverClassName

      public String getConfiguredDriverClassName()
      Specified by:
      getConfiguredDriverClassName in interface BasicJdbcConfiguration
      Returns:
      The driver class name supplied via configuration
    • getDriverClassName

      public String getDriverClassName()
      Specified by:
      getDriverClassName in interface BasicJdbcConfiguration
      Overrides:
      getDriverClassName in class com.zaxxer.hikari.HikariConfig
      Returns:
      The driver class name to be used by the data source
    • getConfiguredUsername

      public String getConfiguredUsername()
      Specified by:
      getConfiguredUsername in interface BasicJdbcConfiguration
      Returns:
      The username supplied via configuration
    • getUsername

      public String getUsername()
      Specified by:
      getUsername in interface BasicJdbcConfiguration
      Overrides:
      getUsername in class com.zaxxer.hikari.HikariConfig
      Returns:
      The username to be used by the data source
    • getConfiguredPassword

      public String getConfiguredPassword()
      Specified by:
      getConfiguredPassword in interface BasicJdbcConfiguration
      Returns:
      The password supplied via configuration
    • getPassword

      public String getPassword()
      Specified by:
      getPassword in interface BasicJdbcConfiguration
      Overrides:
      getPassword in class com.zaxxer.hikari.HikariConfig
      Returns:
      The password to be used by the data source
    • getConfiguredValidationQuery

      public String getConfiguredValidationQuery()
      Specified by:
      getConfiguredValidationQuery in interface BasicJdbcConfiguration
      Returns:
      The validation query supplied via configuration
    • getValidationQuery

      public String getValidationQuery()
      Specified by:
      getValidationQuery in interface BasicJdbcConfiguration
      Returns:
      The validation query to be used by the data source
    • setValidationQuery

      public void setValidationQuery(String validationQuery)
      Setter.
      Parameters:
      validationQuery - string of query
    • getJndiName

      public String getJndiName()
      Get Jndi name.
      Returns:
      jndiName
    • setJndiName

      public void setJndiName(String jndiName)
      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 interface BasicJdbcConfiguration
      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