Example usage for org.springframework.jdbc.datasource.lookup JndiDataSourceLookup setResourceRef

List of usage examples for org.springframework.jdbc.datasource.lookup JndiDataSourceLookup setResourceRef

Introduction

In this page you can find the example usage for org.springframework.jdbc.datasource.lookup JndiDataSourceLookup setResourceRef.

Prototype

public void setResourceRef(boolean resourceRef) 

Source Link

Document

Set whether the lookup occurs in a Java EE container, i.e.

Usage

From source file:uk.org.funcube.fcdw.config.PersistenceConfig.java

@Bean
@Resource(name = "jdbc/funcube")
public DataSource dataSourceLookup() {
    JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
    dsLookup.setResourceRef(true);
    DataSource dataSource = dsLookup.getDataSource("java:comp/env/jdbc/funcube");
    return dataSource;
}

From source file:com.pavikumbhar.javaheart.springconfiguration.DataSourceConfig.java

/**
 <resource-ref>//ww  w . java 2  s . com
<description>Oracle Weblogic console JDBC Data Source</description>
<res-ref-name>jdbc/pgcDataSource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<mapped-name>pgcDataSource</mapped-name>
 </resource-ref>
         
 **/

@Bean(destroyMethod = "")
@Profile("prod")
@Resource(description = "Oracle Weblogic console JDBC Data Source", name = "jdbc/pgcDataSource", type = javax.sql.DataSource.class, authenticationType = javax.annotation.Resource.AuthenticationType.CONTAINER, mappedName = "pgcDataSource")
public DataSource dataSource() {
    final JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
    dsLookup.setResourceRef(true);
    DataSource dataSource = dsLookup.getDataSource("pgcDataSource");
    return dataSource;
}

From source file:de.pksoftware.springstrap.core.config.JndiRdbmsConfigBase.java

/**
  * Creates the DataSource.//from   w w w. j a  va 2s . c  om
  * @return
 * @throws NamingException 
 * @throws IllegalArgumentException 
  */
protected DataSource dataSource() {

    final JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
    dsLookup.setResourceRef(true);

    DataSource dataSource = dsLookup.getDataSource(getJndiDataSourceUri());

    /*
    JndiObjectFactoryBean bean = new JndiObjectFactoryBean();
     bean.setJndiName(getJndiDataSourceUri());
     bean.setProxyInterface(DataSource.class);
     bean.setLookupOnStartup(false);
     try{
        bean.afterPropertiesSet();
     }
     catch(Exception ex){
             
     }
     DataSource dataSource = (DataSource)bean.getObject();
     */

    return dataSource;
}

From source file:hiloTestear.ESNConfiguracionPersistencia.java

@Bean
public DataSource dataSource() {
    final JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
    dsLookup.setResourceRef(true);
    DataSource dataSource = dsLookup.getDataSource(environment.getProperty(PROPERTY_NAME_DATABASE_JNDI));
    return dataSource;
}

From source file:com.activiti.conf.DatabaseConfiguration.java

@Bean
public DataSource dataSource() {
    log.info("Configuring Datasource");

    String dataSourceJndiName = env.getProperty("datasource.jndi.name");
    if (StringUtils.isNotEmpty(dataSourceJndiName)) {

        log.info("Using jndi datasource '" + dataSourceJndiName + "'");
        JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
        dsLookup.setResourceRef(env.getProperty("datasource.jndi.resourceRef", Boolean.class, Boolean.TRUE));
        DataSource dataSource = dsLookup.getDataSource(dataSourceJndiName);
        return dataSource;

    } else {//from ww w . j ava 2s  . c  o  m

        String dataSourceDriver = env.getProperty("datasource.driver", "com.mysql.jdbc.Driver");
        String dataSourceUrl = env.getProperty("datasource.url",
                "jdbc:mysql://127.0.0.1:3306/activiti6admin?characterEncoding=UTF-8");

        String dataSourceUsername = env.getProperty("datasource.username", "alfresco");
        String dataSourcePassword = env.getProperty("datasource.password", "alfresco");

        Integer minPoolSize = env.getProperty("datasource.min-pool-size", Integer.class);
        if (minPoolSize == null) {
            minPoolSize = 5;
        }

        Integer maxPoolSize = env.getProperty("datasource.max-pool-size", Integer.class);
        if (maxPoolSize == null) {
            maxPoolSize = 20;
        }

        Integer acquireIncrement = env.getProperty("datasource.acquire-increment", Integer.class);
        if (acquireIncrement == null) {
            acquireIncrement = 1;
        }

        String preferredTestQuery = env.getProperty("datasource.preferred-test-query");

        Boolean testConnectionOnCheckin = env.getProperty("datasource.test-connection-on-checkin",
                Boolean.class);
        if (testConnectionOnCheckin == null) {
            testConnectionOnCheckin = true;
        }

        Boolean testConnectionOnCheckOut = env.getProperty("datasource.test-connection-on-checkout",
                Boolean.class);
        if (testConnectionOnCheckOut == null) {
            testConnectionOnCheckOut = true;
        }

        Integer maxIdleTime = env.getProperty("datasource.max-idle-time", Integer.class);
        if (maxIdleTime == null) {
            maxIdleTime = 1800;
        }

        Integer maxIdleTimeExcessConnections = env.getProperty("datasource.max-idle-time-excess-connections",
                Integer.class);
        if (maxIdleTimeExcessConnections == null) {
            maxIdleTimeExcessConnections = 1800;
        }

        if (log.isInfoEnabled()) {
            log.info("Configuring Datasource with following properties (omitted password for security)");
            log.info("datasource driver: " + dataSourceDriver);
            log.info("datasource url : " + dataSourceUrl);
            log.info("datasource user name : " + dataSourceUsername);
            log.info("Min pool size | Max pool size | acquire increment : " + minPoolSize + " | " + maxPoolSize
                    + " | " + acquireIncrement);
        }

        ComboPooledDataSource ds = new ComboPooledDataSource();
        try {
            ds.setDriverClass(dataSourceDriver);
        } catch (PropertyVetoException e) {
            log.error("Could not set Jdbc Driver class", e);
            return null;
        }

        // Connection settings
        ds.setJdbcUrl(dataSourceUrl);
        ds.setUser(dataSourceUsername);
        ds.setPassword(dataSourcePassword);

        // Pool config: see http://www.mchange.com/projects/c3p0/#configuration
        ds.setMinPoolSize(minPoolSize);
        ds.setMaxPoolSize(maxPoolSize);
        ds.setAcquireIncrement(acquireIncrement);
        if (preferredTestQuery != null) {
            ds.setPreferredTestQuery(preferredTestQuery);
        }
        ds.setTestConnectionOnCheckin(testConnectionOnCheckin);
        ds.setTestConnectionOnCheckout(testConnectionOnCheckOut);
        ds.setMaxIdleTimeExcessConnections(maxIdleTimeExcessConnections);
        ds.setMaxIdleTime(maxIdleTime);

        return ds;
    }
}

From source file:org.activiti.app.conf.DatabaseConfiguration.java

@Bean
public DataSource dataSource() {
    log.info("Configuring Datasource");

    String dataSourceJndiName = env.getProperty("datasource.jndi.name");
    if (StringUtils.isNotEmpty(dataSourceJndiName)) {

        log.info("Using jndi datasource '" + dataSourceJndiName + "'");
        JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
        dsLookup.setResourceRef(env.getProperty("datasource.jndi.resourceRef", Boolean.class, Boolean.TRUE));
        DataSource dataSource = dsLookup.getDataSource(dataSourceJndiName);
        return dataSource;

    } else {// www . j a  va 2 s. co m

        String dataSourceDriver = env.getProperty("datasource.driver", "org.h2.Driver");
        String dataSourceUrl = env.getProperty("datasource.url", "jdbc:h2:mem:activiti;DB_CLOSE_DELAY=-1");

        String dataSourceUsername = env.getProperty("datasource.username", "sa");
        String dataSourcePassword = env.getProperty("datasource.password", "");

        Integer minPoolSize = env.getProperty("datasource.min-pool-size", Integer.class);
        if (minPoolSize == null) {
            minPoolSize = 10;
        }

        Integer maxPoolSize = env.getProperty("datasource.max-pool-size", Integer.class);
        if (maxPoolSize == null) {
            maxPoolSize = 100;
        }

        Integer acquireIncrement = env.getProperty("datasource.acquire-increment", Integer.class);
        if (acquireIncrement == null) {
            acquireIncrement = 5;
        }

        String preferredTestQuery = env.getProperty("datasource.preferred-test-query");

        Boolean testConnectionOnCheckin = env.getProperty("datasource.test-connection-on-checkin",
                Boolean.class);
        if (testConnectionOnCheckin == null) {
            testConnectionOnCheckin = true;
        }

        Boolean testConnectionOnCheckOut = env.getProperty("datasource.test-connection-on-checkout",
                Boolean.class);
        if (testConnectionOnCheckOut == null) {
            testConnectionOnCheckOut = true;
        }

        Integer maxIdleTime = env.getProperty("datasource.max-idle-time", Integer.class);
        if (maxIdleTime == null) {
            maxIdleTime = 1800;
        }

        Integer maxIdleTimeExcessConnections = env.getProperty("datasource.max-idle-time-excess-connections",
                Integer.class);
        if (maxIdleTimeExcessConnections == null) {
            maxIdleTimeExcessConnections = 1800;
        }

        if (log.isInfoEnabled()) {
            log.info("Configuring Datasource with following properties (omitted password for security)");
            log.info("datasource driver: " + dataSourceDriver);
            log.info("datasource url : " + dataSourceUrl);
            log.info("datasource user name : " + dataSourceUsername);
            log.info("Min pool size | Max pool size | acquire increment : " + minPoolSize + " | " + maxPoolSize
                    + " | " + acquireIncrement);
        }

        ComboPooledDataSource ds = new ComboPooledDataSource();
        try {
            ds.setDriverClass(dataSourceDriver);
        } catch (PropertyVetoException e) {
            log.error("Could not set Jdbc Driver class", e);
            return null;
        }

        // Connection settings
        ds.setJdbcUrl(dataSourceUrl);
        ds.setUser(dataSourceUsername);
        ds.setPassword(dataSourcePassword);

        // Pool config: see http://www.mchange.com/projects/c3p0/#configuration
        ds.setMinPoolSize(minPoolSize);
        ds.setMaxPoolSize(maxPoolSize);
        ds.setAcquireIncrement(acquireIncrement);
        if (preferredTestQuery != null) {
            ds.setPreferredTestQuery(preferredTestQuery);
        }
        ds.setTestConnectionOnCheckin(testConnectionOnCheckin);
        ds.setTestConnectionOnCheckout(testConnectionOnCheckOut);
        ds.setMaxIdleTimeExcessConnections(maxIdleTimeExcessConnections);
        ds.setMaxIdleTime(maxIdleTime);

        return ds;
    }
}

From source file:org.activiti.conf.DatabaseConfiguration.java

@Bean
public DataSource dataSource() {
    log.info("Configuring Datasource");

    String dataSourceJndiName = env.getProperty("datasource.jndi.name");
    if (StringUtils.isNotEmpty(dataSourceJndiName)) {

        log.info("Using jndi datasource '" + dataSourceJndiName + "'");
        JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
        dsLookup.setResourceRef(env.getProperty("datasource.jndi.resourceRef", Boolean.class, Boolean.TRUE));
        DataSource dataSource = dsLookup.getDataSource(dataSourceJndiName);
        return dataSource;

    } else {/*  w ww  . ja  v a  2  s  .co  m*/

        String dataSourceDriver = env.getProperty("datasource.driver", "com.mysql.jdbc.Driver");
        String dataSourceUrl = env.getProperty("datasource.url",
                "jdbc:mysql://127.0.0.1:3306/flowable?characterEncoding=UTF-8");

        String dataSourceUsername = env.getProperty("datasource.username", "flowable");
        String dataSourcePassword = env.getProperty("datasource.password", "flowable");

        Integer minPoolSize = env.getProperty("datasource.min-pool-size", Integer.class);
        if (minPoolSize == null) {
            minPoolSize = 5;
        }

        Integer maxPoolSize = env.getProperty("datasource.max-pool-size", Integer.class);
        if (maxPoolSize == null) {
            maxPoolSize = 20;
        }

        Integer acquireIncrement = env.getProperty("datasource.acquire-increment", Integer.class);
        if (acquireIncrement == null) {
            acquireIncrement = 1;
        }

        String preferredTestQuery = env.getProperty("datasource.preferred-test-query");

        Boolean testConnectionOnCheckin = env.getProperty("datasource.test-connection-on-checkin",
                Boolean.class);
        if (testConnectionOnCheckin == null) {
            testConnectionOnCheckin = true;
        }

        Boolean testConnectionOnCheckOut = env.getProperty("datasource.test-connection-on-checkout",
                Boolean.class);
        if (testConnectionOnCheckOut == null) {
            testConnectionOnCheckOut = true;
        }

        Integer maxIdleTime = env.getProperty("datasource.max-idle-time", Integer.class);
        if (maxIdleTime == null) {
            maxIdleTime = 1800;
        }

        Integer maxIdleTimeExcessConnections = env.getProperty("datasource.max-idle-time-excess-connections",
                Integer.class);
        if (maxIdleTimeExcessConnections == null) {
            maxIdleTimeExcessConnections = 1800;
        }

        if (log.isInfoEnabled()) {
            log.info("Configuring Datasource with following properties (omitted password for security)");
            log.info("datasource driver: " + dataSourceDriver);
            log.info("datasource url : " + dataSourceUrl);
            log.info("datasource user name : " + dataSourceUsername);
            log.info("Min pool size | Max pool size | acquire increment : " + minPoolSize + " | " + maxPoolSize
                    + " | " + acquireIncrement);
        }

        ComboPooledDataSource ds = new ComboPooledDataSource();
        try {
            ds.setDriverClass(dataSourceDriver);
        } catch (PropertyVetoException e) {
            log.error("Could not set Jdbc Driver class", e);
            return null;
        }

        // Connection settings
        ds.setJdbcUrl(dataSourceUrl);
        ds.setUser(dataSourceUsername);
        ds.setPassword(dataSourcePassword);

        // Pool config: see http://www.mchange.com/projects/c3p0/#configuration
        ds.setMinPoolSize(minPoolSize);
        ds.setMaxPoolSize(maxPoolSize);
        ds.setAcquireIncrement(acquireIncrement);
        if (preferredTestQuery != null) {
            ds.setPreferredTestQuery(preferredTestQuery);
        }
        ds.setTestConnectionOnCheckin(testConnectionOnCheckin);
        ds.setTestConnectionOnCheckout(testConnectionOnCheckOut);
        ds.setMaxIdleTimeExcessConnections(maxIdleTimeExcessConnections);
        ds.setMaxIdleTime(maxIdleTime);

        return ds;
    }
}

From source file:org.flowable.admin.conf.DatabaseConfiguration.java

@Bean
public DataSource dataSource() {
    log.info("Configuring Datasource");

    String dataSourceJndiName = env.getProperty("datasource.jndi.name");
    if (StringUtils.isNotEmpty(dataSourceJndiName)) {

        log.info("Using jndi datasource '{}'", dataSourceJndiName);
        JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
        dsLookup.setResourceRef(env.getProperty("datasource.jndi.resourceRef", Boolean.class, Boolean.TRUE));
        DataSource dataSource = dsLookup.getDataSource(dataSourceJndiName);
        return dataSource;

    } else {//from   w  w  w . j av  a  2s.c  om

        String dataSourceDriver = env.getProperty("datasource.driver", "com.mysql.jdbc.Driver");
        String dataSourceUrl = env.getProperty("datasource.url",
                "jdbc:mysql://127.0.0.1:3306/flowable?characterEncoding=UTF-8");

        String dataSourceUsername = env.getProperty("datasource.username", "flowable");
        String dataSourcePassword = env.getProperty("datasource.password", "flowable");

        Integer minPoolSize = env.getProperty("datasource.min-pool-size", Integer.class);
        if (minPoolSize == null) {
            minPoolSize = 5;
        }

        Integer maxPoolSize = env.getProperty("datasource.max-pool-size", Integer.class);
        if (maxPoolSize == null) {
            maxPoolSize = 20;
        }

        Integer acquireIncrement = env.getProperty("datasource.acquire-increment", Integer.class);
        if (acquireIncrement == null) {
            acquireIncrement = 1;
        }

        String preferredTestQuery = env.getProperty("datasource.preferred-test-query");

        Boolean testConnectionOnCheckin = env.getProperty("datasource.test-connection-on-checkin",
                Boolean.class);
        if (testConnectionOnCheckin == null) {
            testConnectionOnCheckin = true;
        }

        Boolean testConnectionOnCheckOut = env.getProperty("datasource.test-connection-on-checkout",
                Boolean.class);
        if (testConnectionOnCheckOut == null) {
            testConnectionOnCheckOut = true;
        }

        Integer maxIdleTime = env.getProperty("datasource.max-idle-time", Integer.class);
        if (maxIdleTime == null) {
            maxIdleTime = 1800;
        }

        Integer maxIdleTimeExcessConnections = env.getProperty("datasource.max-idle-time-excess-connections",
                Integer.class);
        if (maxIdleTimeExcessConnections == null) {
            maxIdleTimeExcessConnections = 1800;
        }

        if (log.isInfoEnabled()) {
            log.info("Configuring Datasource with following properties (omitted password for security)");
            log.info("datasource driver : {}", dataSourceDriver);
            log.info("datasource url : {}", dataSourceUrl);
            log.info("datasource user name : {}", dataSourceUsername);
            log.info("Min pool size | Max pool size | acquire increment : {} | {} | {}", minPoolSize,
                    maxPoolSize, acquireIncrement);
        }

        ComboPooledDataSource ds = new ComboPooledDataSource();
        try {
            ds.setDriverClass(dataSourceDriver);
        } catch (PropertyVetoException e) {
            log.error("Could not set Jdbc Driver class", e);
            return null;
        }

        // Connection settings
        ds.setJdbcUrl(dataSourceUrl);
        ds.setUser(dataSourceUsername);
        ds.setPassword(dataSourcePassword);

        // Pool config: see http://www.mchange.com/projects/c3p0/#configuration
        ds.setMinPoolSize(minPoolSize);
        ds.setMaxPoolSize(maxPoolSize);
        ds.setAcquireIncrement(acquireIncrement);
        if (preferredTestQuery != null) {
            ds.setPreferredTestQuery(preferredTestQuery);
        }
        ds.setTestConnectionOnCheckin(testConnectionOnCheckin);
        ds.setTestConnectionOnCheckout(testConnectionOnCheckOut);
        ds.setMaxIdleTimeExcessConnections(maxIdleTimeExcessConnections);
        ds.setMaxIdleTime(maxIdleTime);

        return ds;
    }
}

From source file:org.flowable.app.conf.DatabaseConfiguration.java

@Bean
public DataSource dataSource() {
    log.info("Configuring Datasource");

    String dataSourceJndiName = env.getProperty("datasource.jndi.name");
    if (StringUtils.isNotEmpty(dataSourceJndiName)) {

        log.info("Using jndi datasource '{}'", dataSourceJndiName);
        JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
        dsLookup.setResourceRef(env.getProperty("datasource.jndi.resourceRef", Boolean.class, Boolean.TRUE));
        DataSource dataSource = dsLookup.getDataSource(dataSourceJndiName);
        return dataSource;

    } else {//from w ww.  ja  v  a  2 s  .c om

        String dataSourceDriver = env.getProperty("datasource.driver", "org.h2.Driver");
        String dataSourceUrl = env.getProperty("datasource.url", "jdbc:h2:mem:flowable;DB_CLOSE_DELAY=-1");

        String dataSourceUsername = env.getProperty("datasource.username", "sa");
        String dataSourcePassword = env.getProperty("datasource.password", "");

        Integer minPoolSize = env.getProperty("datasource.min-pool-size", Integer.class);
        if (minPoolSize == null) {
            minPoolSize = 10;
        }

        Integer maxPoolSize = env.getProperty("datasource.max-pool-size", Integer.class);
        if (maxPoolSize == null) {
            maxPoolSize = 100;
        }

        Integer acquireIncrement = env.getProperty("datasource.acquire-increment", Integer.class);
        if (acquireIncrement == null) {
            acquireIncrement = 5;
        }

        String preferredTestQuery = env.getProperty("datasource.preferred-test-query");

        Boolean testConnectionOnCheckin = env.getProperty("datasource.test-connection-on-checkin",
                Boolean.class);
        if (testConnectionOnCheckin == null) {
            testConnectionOnCheckin = true;
        }

        Boolean testConnectionOnCheckOut = env.getProperty("datasource.test-connection-on-checkout",
                Boolean.class);
        if (testConnectionOnCheckOut == null) {
            testConnectionOnCheckOut = true;
        }

        Integer maxIdleTime = env.getProperty("datasource.max-idle-time", Integer.class);
        if (maxIdleTime == null) {
            maxIdleTime = 1800;
        }

        Integer maxIdleTimeExcessConnections = env.getProperty("datasource.max-idle-time-excess-connections",
                Integer.class);
        if (maxIdleTimeExcessConnections == null) {
            maxIdleTimeExcessConnections = 1800;
        }

        if (log.isInfoEnabled()) {
            log.info("Configuring Datasource with following properties (omitted password for security)");
            log.info("datasource driver : {}", dataSourceDriver);
            log.info("datasource url : {}", dataSourceUrl);
            log.info("datasource user name : {}", dataSourceUsername);
            log.info("Min pool size | Max pool size | acquire increment : {} | {} | {}", minPoolSize,
                    maxPoolSize, acquireIncrement);
        }

        ComboPooledDataSource ds = new ComboPooledDataSource();
        try {
            ds.setDriverClass(dataSourceDriver);
        } catch (PropertyVetoException e) {
            log.error("Could not set Jdbc Driver class", e);
            return null;
        }

        // Connection settings
        ds.setJdbcUrl(dataSourceUrl);
        ds.setUser(dataSourceUsername);
        ds.setPassword(dataSourcePassword);

        // Pool config: see http://www.mchange.com/projects/c3p0/#configuration
        ds.setMinPoolSize(minPoolSize);
        ds.setMaxPoolSize(maxPoolSize);
        ds.setAcquireIncrement(acquireIncrement);
        if (preferredTestQuery != null) {
            ds.setPreferredTestQuery(preferredTestQuery);
        }
        ds.setTestConnectionOnCheckin(testConnectionOnCheckin);
        ds.setTestConnectionOnCheckout(testConnectionOnCheckOut);
        ds.setMaxIdleTimeExcessConnections(maxIdleTimeExcessConnections);
        ds.setMaxIdleTime(maxIdleTime);

        return ds;
    }
}

From source file:org.flowable.app.conf.FlowableAppDatasourceUtil.java

public static DataSource createDataSource(Environment environment) {

    String dataSourceJndiName = environment.getProperty("datasource.jndi.name");
    if (StringUtils.isNotEmpty(dataSourceJndiName)) {

        LOGGER.info("Using jndi datasource '{}'", dataSourceJndiName);
        JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
        dsLookup.setResourceRef(
                environment.getProperty("datasource.jndi.resourceRef", Boolean.class, Boolean.TRUE));
        DataSource dataSource = dsLookup.getDataSource(dataSourceJndiName);
        return dataSource;

    } else {//from   w ww .  ja va2  s  .c  om

        String url = environment.getProperty("datasource.url", "jdbc:h2:mem:flowable;DB_CLOSE_DELAY=1000");
        String driver = environment.getProperty("datasource.driver", "org.h2.Driver");
        String username = environment.getProperty("datasource.username", "sa");
        String password = environment.getProperty("datasource.password", "");

        HikariDataSource dataSource = new HikariDataSource();
        dataSource.setJdbcUrl(url);
        dataSource.setDriverClassName(driver);
        dataSource.setUsername(username);
        dataSource.setPassword(password);

        /*
         * Connection pool settings (see https://github.com/brettwooldridge/HikariCP)
         */

        // Timeout to wait for a connection of the pool
        Long connectionTimeout = environment.getProperty("datasource.connection-timeout", Long.class);
        if (connectionTimeout == null) {
            // Backwards compatible property name (pre 6.3.0)
            connectionTimeout = environment.getProperty("datasource.connection.timeout", Long.class);
        }
        if (connectionTimeout != null) {
            dataSource.setConnectionTimeout(connectionTimeout);
        }

        // Minimum amount of connections to keep idle in the pool
        Integer minIdle = environment.getProperty("datasource.min-pool-size", Integer.class);
        if (minIdle == null) {
            // Backwards compatible property name (pre 6.3.0)
            minIdle = environment.getProperty("datasource.connection.minidle", Integer.class);
        }
        if (minIdle != null) {
            dataSource.setMinimumIdle(minIdle);
        }

        // Maximum amount of connections in the pool
        Integer maxPoolSize = environment.getProperty("datasource.max-pool-size", Integer.class);
        if (maxPoolSize == null) {
            // Backwards compatible property name (pre 6.3.0)
            maxPoolSize = environment.getProperty("datasource.connection.maxpoolsize", Integer.class);
        }
        if (maxPoolSize != null) {
            dataSource.setMaximumPoolSize(maxPoolSize);
        }

        // Time in milliseconds to indicate when a connection will be removed from the pool. 
        // Use 0 to never remove an idle connection from the pool 
        Long idleTimeout = environment.getProperty("datasource.max-idle-time", Long.class);
        if (idleTimeout != null) {
            // Property has been historically expressed in seconds, but Hikari expects milliseconds
            idleTimeout = idleTimeout * 1000;
        } else if (idleTimeout == null) {
            // Backwards compatible property name (pre 6.3.0)
            idleTimeout = environment.getProperty("datasource.connection.idletimeout", Long.class);
        }
        if (idleTimeout != null) {
            dataSource.setIdleTimeout(idleTimeout);
        }

        // The maximum lifetime of a connection in the pool
        Long maxLifetime = environment.getProperty("datasource.connection.max-lifetime", Long.class);
        if (maxLifetime == null) {
            maxLifetime = environment.getProperty("datasource.connection.maxlifetime", Long.class);
        }
        if (maxLifetime != null) {
            dataSource.setMaxLifetime(maxLifetime);
        }

        // Test query
        String testQuery = environment.getProperty("datasource.test-query");
        if (testQuery == null) {
            // Backwards compatible property name (pre 6.3.0)
            testQuery = environment.getProperty("datasource.preferred-test-query");
        }
        if (testQuery != null) {
            dataSource.setConnectionTestQuery(testQuery);
        }

        if (LOGGER.isInfoEnabled()) {
            LOGGER.info("Configuring datasource with following properties");
            LOGGER.info("Datasource driver: {}", driver);
            LOGGER.info("Datasource url: {}", url);
            LOGGER.info("Datasource user name: {}", username);
            LOGGER.info("Min pool size | Max pool size | {} | {}", minIdle != null ? minIdle : "default",
                    maxPoolSize != null ? maxPoolSize : "default");
        }

        return dataSource;
    }

}