Class DatasourceConfiguration

  • All Implemented Interfaces:
    BasicJdbcConfiguration

    @EachProperty(value="datasources",
                  primary="default")
    @Context
    public class DatasourceConfiguration
    extends java.lang.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
    • Constructor Detail

      • DatasourceConfiguration

        public DatasourceConfiguration​(@Parameter
                                       java.lang.String name)
                                throws java.sql.SQLException
        Constructor.
        Parameters:
        name - name that comes from properties
        Throws:
        java.sql.SQLException
    • Method Detail

      • getPoolDataSource

        public oracle.ucp.jdbc.PoolDataSource getPoolDataSource()
        Returns:
        the pool data source
        Since:
        4.1
      • getName

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

        public void setName​(java.lang.String name)
                     throws java.sql.SQLException
        Parameters:
        name - the name of the datasource
        Throws:
        java.sql.SQLException - an sql exception
      • setDriverClassName

        public void setDriverClassName​(java.lang.String driverClassName)
        Specified by:
        setDriverClassName in interface BasicJdbcConfiguration
        Parameters:
        driverClassName - Sets the driver class name
      • getUrl

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

        public void setUrl​(java.lang.String url)
        Specified by:
        setUrl in interface BasicJdbcConfiguration
        Parameters:
        url - Sets the url
      • getUsername

        public java.lang.String getUsername()
        Specified by:
        getUsername in interface BasicJdbcConfiguration
        Returns:
        The username to be used by the data source
      • setUsername

        public void setUsername​(java.lang.String username)
        Specified by:
        setUsername in interface BasicJdbcConfiguration
        Parameters:
        username - the username
      • getPassword

        public java.lang.String getPassword()
        Specified by:
        getPassword in interface BasicJdbcConfiguration
        Returns:
        The password to be used by the data source
      • setPassword

        public void setPassword​(java.lang.String password)
        Specified by:
        setPassword in interface BasicJdbcConfiguration
        Parameters:
        password - Sets the password
      • setValidationQuery

        public void setValidationQuery​(java.lang.String validationQuery)
      • initialize

        @PostConstruct
        public void initialize()
        Configures the missing properties of the data source from the calculated settings.
        Since:
        4.0.2