Java Code Examples for com.mchange.v2.c3p0.ComboPooledDataSource#setPassword()

The following examples show how to use com.mchange.v2.c3p0.ComboPooledDataSource#setPassword() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: C3P0DataSourceFactoryBean.java    From cloud-config with MIT License 6 votes vote down vote up
private ComboPooledDataSource createNewDataSource() throws Exception {
    ComboPooledDataSource c3p0DataSource = new ComboPooledDataSource();

    c3p0DataSource.setDriverClass(config.getDriverClassName()); //loads the jdbc driver
    c3p0DataSource.setJdbcUrl(config.getJdbcUrl());
    c3p0DataSource.setUser(config.getUserName());
    c3p0DataSource.setPassword(config.getPassword());

    // the settings below are optional -- c3p0 can work with defaults
    c3p0DataSource.setMinPoolSize(config.getMinPoolSize());
    c3p0DataSource.setMaxPoolSize(config.getMaxPoolSize());
    c3p0DataSource.setAcquireIncrement(config.getAcquireIncrement());
    c3p0DataSource.setMaxStatements(config.getMaxStatements());
    c3p0DataSource.setIdleConnectionTestPeriod(config.getIdleTestPeriod());
    c3p0DataSource.setMaxIdleTime(config.getMaxIdleTime());

    return c3p0DataSource;
}
 
Example 2
Source File: DataSourceFactory.java    From copper-engine with Apache License 2.0 6 votes vote down vote up
public static ComboPooledDataSource createDataSource(Properties props) {
    try {
        final String jdbcUrl = trim(props.getProperty(ConfigParameter.DS_JDBC_URL.getKey()));
        final String user = trim(props.getProperty(ConfigParameter.DS_USER.getKey()));
        final String password = trim(props.getProperty(ConfigParameter.DS_PASSWORD.getKey()));
        final String driverClass = trim(props.getProperty(ConfigParameter.DS_DRIVER_CLASS.getKey()));
        final int minPoolSize = Integer.valueOf(props.getProperty(ConfigParameter.DS_MIN_POOL_SIZE.getKey(), Integer.toString(Runtime.getRuntime().availableProcessors())));
        final int maxPoolSize = Integer.valueOf(props.getProperty(ConfigParameter.DS_MAX_POOL_SIZE.getKey(), Integer.toString(2 * Runtime.getRuntime().availableProcessors())));
        ComboPooledDataSource ds = new ComboPooledDataSource();
        ds.setJdbcUrl(jdbcUrl.replace("${NOW}", Long.toString(System.currentTimeMillis())));
        if (!isNullOrEmpty(user))
            ds.setUser(user);
        if (!isNullOrEmpty(password))
            ds.setPassword(password);
        if (!isNullOrEmpty(driverClass))
            ds.setDriverClass(driverClass);
        ds.setMinPoolSize(minPoolSize);
        ds.setInitialPoolSize(minPoolSize);
        ds.setMaxPoolSize(maxPoolSize);
        return ds;
    } catch (Exception e) {
        throw new RuntimeException("Unable to create datasource", e);
    }
}
 
Example 3
Source File: C3P0PoolManager.java    From openzaly with Apache License 2.0 6 votes vote down vote up
public static void initPool(Properties pro) throws Exception {
	String jdbcUrl = getDBUrl(pro);
	String userName = trimToNull(pro, JdbcConst.MYSQL_USER_NAME);
	String password = trimToNull(pro, JdbcConst.MYSQL_PASSWORD);

	cpds = new ComboPooledDataSource();
	cpds.setDriverClass(MYSQL_JDBC_DRIVER); // loads the jdbc driver
	cpds.setJdbcUrl(jdbcUrl);
	cpds.setUser(userName);
	cpds.setPassword(password);
	int inititalSize = Integer.valueOf(trimToNull(pro, JdbcConst.MYSQL_INITIAL_SIZE, "10"));
	int maxSize = Integer.valueOf(trimToNull(pro, JdbcConst.MYSQL_MAX_SIZE, "100"));
	cpds.setInitialPoolSize(inititalSize);// 初始创建默认10个连接
	cpds.setMaxPoolSize(maxSize);// 最大默认100个
	int inc = (maxSize - inititalSize) / 5;
	cpds.setAcquireIncrement(Integer.max(1, inc));// 每次创建10个

	int maxIdle = Integer.valueOf(trimToNull(pro, JdbcConst.MYSQL_MAX_IDLE, "60"));
	cpds.setMaxIdleTime(maxIdle);// 最大空闲时间
	
	SqlLog.info("openzaly init mysql master connection pool cpds={}", cpds);
}
 
Example 4
Source File: DatabaseHandler.java    From xyz-hub with Apache License 2.0 6 votes vote down vote up
private ComboPooledDataSource getComboPooledDataSource(String host, int port, String database, String user,
                                                       String password, String applicationName, int maxPostgreSQLConnections) {
    final ComboPooledDataSource cpds = new ComboPooledDataSource();

    cpds.setJdbcUrl(
            String.format("jdbc:postgresql://%1$s:%2$d/%3$s?ApplicationName=%4$s&tcpKeepAlive=true", host, port, database, applicationName));

    cpds.setUser(user);
    cpds.setPassword(password);

    cpds.setInitialPoolSize(1);
    cpds.setMinPoolSize(1);
    cpds.setAcquireIncrement(1);
    cpds.setMaxPoolSize(maxPostgreSQLConnections);
    cpds.setCheckoutTimeout( CONNECTION_CHECKOUT_TIMEOUT_SECONDS * 1000 );
    cpds.setConnectionCustomizerClassName(DatabaseHandler.XyzConnectionCustomizer.class.getName());
    return cpds;
}
 
Example 5
Source File: C3P0DataSourceProvider.java    From minnal with Apache License 2.0 6 votes vote down vote up
protected PooledDataSource createDataSource() {
	logger.info("Creating the data source with the configuration {}", configuration);
	if (configuration == null) {
		logger.error("Database configuration is not set");
		throw new MinnalException("Database configuration is not set");
	}
	ComboPooledDataSource dataSource = new ComboPooledDataSource();
	try {
		Class.forName(configuration.getDriverClass());
		dataSource.setJdbcUrl(configuration.getUrl());
		dataSource.setUser(configuration.getUsername());
		dataSource.setPassword(configuration.getPassword());
		dataSource.setIdleConnectionTestPeriod(configuration.getIdleConnectionTestPeriod());
		dataSource.setInitialPoolSize(configuration.getMinSize());
		dataSource.setMaxPoolSize(configuration.getMaxSize());
	} catch (Exception e) {
		logger.error("Failed while creating the data source", e);
		throw new MinnalException("Failed while configuring the data source", e);
	}
	return dataSource;
}
 
Example 6
Source File: MysqlHelper.java    From WebCollector with GNU General Public License v3.0 5 votes vote down vote up
public DataSource createDataSource(String url, String username, String password, int initialSize, int maxPoolSize) throws PropertyVetoException {
    ComboPooledDataSource dataSource = new ComboPooledDataSource();
    dataSource.setDriverClass("com.mysql.jdbc.Driver");
    dataSource.setJdbcUrl(url);
    dataSource.setUser(username);
    dataSource.setPassword(password);
    dataSource.setInitialPoolSize(initialSize);
    dataSource.setMaxPoolSize(maxPoolSize);
    dataSource.setTestConnectionOnCheckout(true);
    return dataSource;
}
 
Example 7
Source File: C3P0DataSource.java    From sqlg with MIT License 5 votes vote down vote up
public static C3P0DataSource create(final Configuration configuration) throws Exception {
    Preconditions.checkState(configuration.containsKey(SqlgGraph.JDBC_URL));
    Preconditions.checkState(configuration.containsKey("jdbc.username"));
    Preconditions.checkState(configuration.containsKey("jdbc.password"));

    String jdbcUrl = configuration.getString(SqlgGraph.JDBC_URL);
    SqlgPlugin sqlgPlugin = SqlgPlugin.load(jdbcUrl);
    SqlDialect sqlDialect = sqlgPlugin.instantiateDialect();

    String driver = sqlgPlugin.getDriverFor(jdbcUrl);
    String username = configuration.getString("jdbc.username");
    String password = configuration.getString("jdbc.password");

    ComboPooledDataSource comboPooledDataSource = new ComboPooledDataSource();
    comboPooledDataSource.setDriverClass(driver);
    comboPooledDataSource.setJdbcUrl(jdbcUrl);
    comboPooledDataSource.setMaxPoolSize(configuration.getInt("maxPoolSize", 100));
    comboPooledDataSource.setMaxIdleTime(configuration.getInt("maxIdleTime", 3600));
    comboPooledDataSource.setAcquireRetryAttempts(configuration.getInt("jdbc.acquireRetryAttempts", 30));
    comboPooledDataSource.setForceUseNamedDriverClass(true);
    if (!StringUtils.isEmpty(username)) {
        comboPooledDataSource.setUser(username);
    }

    if (!StringUtils.isEmpty(password)) {
        comboPooledDataSource.setPassword(password);
    }

    return new C3P0DataSource(jdbcUrl, comboPooledDataSource, sqlDialect);
}
 
Example 8
Source File: DataSourceUtils.java    From hasor with Apache License 2.0 5 votes vote down vote up
public static DataSource loadDB(String dbID, Settings settings) throws Throwable {
    // 1.获取数据库连接配置信息
    String driverString = settings.getString(dbID + ".driver");
    String urlString = settings.getString(dbID + ".url");
    String userString = settings.getString(dbID + ".user");
    String pwdString = settings.getString(dbID + ".password");
    // 2.创建数据库连接池
    int poolMaxSize = 40;
    logger.info("C3p0 Pool Info maxSize is ‘%s’ driver is ‘%s’ jdbcUrl is‘%s’", poolMaxSize, driverString, urlString);
    ComboPooledDataSource dataSource = new ComboPooledDataSource();
    dataSource.setDriverClass(driverString);
    dataSource.setJdbcUrl(urlString);
    dataSource.setUser(userString);
    dataSource.setPassword(pwdString);
    dataSource.setMaxPoolSize(poolMaxSize);
    dataSource.setInitialPoolSize(1);
    // dataSource.setAutomaticTestTable("DB_TEST_ATest001");
    dataSource.setIdleConnectionTestPeriod(18000);
    dataSource.setCheckoutTimeout(3000);
    dataSource.setTestConnectionOnCheckin(true);
    dataSource.setAcquireRetryDelay(1000);
    dataSource.setAcquireRetryAttempts(30);
    dataSource.setAcquireIncrement(1);
    dataSource.setMaxIdleTime(25000);
    // 3.启用默认事务拦截器
    return dataSource;
}
 
Example 9
Source File: Database.java    From SQLite-sync.com with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public Database() {

        String version = "";
        try {
            String resourceName = "project.properties";
            ClassLoader loader = Thread.currentThread().getContextClassLoader();
            Properties props = new Properties();
            try(InputStream resourceStream = loader.getResourceAsStream(resourceName)) {
                props.load(resourceStream);
            }
            version = props.getProperty("version");
        } catch (IOException ex){
            Logs.write(Logs.Level.ERROR, "GetVersionOfSQLiteSyncCOM: " + ex.getMessage());
        }
        SQLiteSyncVersion = version;

        SQLiteSyncConfig.Load();

        try {
            cpds = new ComboPooledDataSource();
            cpds.setDriverClass(SQLiteSyncConfig.DBDRIVER); //loads the jdbc driver
            cpds.setJdbcUrl(SQLiteSyncConfig.DBURL);
            cpds.setUser(SQLiteSyncConfig.DBUSER);
            cpds.setPassword(SQLiteSyncConfig.DBPASS);

            // the settings below are optional -- c3p0 can work with defaults
            cpds.setMinPoolSize(3);
            cpds.setAcquireIncrement(3);
            cpds.setMaxPoolSize(10);
            cpds.setIdleConnectionTestPeriod(300);
            cpds.setMaxIdleTime(240);
            cpds.setTestConnectionOnCheckin(false);
            cpds.setMaxStatements(2000);
            cpds.setMaxStatementsPerConnection(100);

        } catch (PropertyVetoException e){
            Logs.write(Logs.Level.ERROR, "Database constructor: " + e.getMessage());
        }
    }
 
Example 10
Source File: CompareWithPopularPool.java    From clearpool with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testC3p0() throws Exception {
  ComboPooledDataSource dataSource = new ComboPooledDataSource();
  dataSource.setMinPoolSize(this.corePoolSize);
  dataSource.setMaxPoolSize(this.maxPoolSize);
  dataSource.setDriverClass(this.driverClassName);
  dataSource.setJdbcUrl(this.url);
  dataSource.setUser(this.username);
  dataSource.setPassword(this.password);
  for (int i = 0; i < this.loop; ++i) {
    ThreadProcessUtils.process(dataSource, "c3p0", this.count, threadCount, physicalCon);
  }
  System.out.println();
}
 
Example 11
Source File: OrderServiceApplication.java    From tcc-transaction with Apache License 2.0 5 votes vote down vote up
@Bean
@Profile("db")
public DataSource tccDataSource() throws Exception {
    ComboPooledDataSource dataSource = new ComboPooledDataSource();
    dataSource.setDriverClass("com.mysql.jdbc.Driver");
    dataSource.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/TCC?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useSSL=false");
    dataSource.setUser("root");
    dataSource.setPassword("admin");
    return dataSource;
}
 
Example 12
Source File: RedPacketServiceApplication.java    From tcc-transaction with Apache License 2.0 5 votes vote down vote up
@Bean
@Profile("db")
public DataSource tccDataSource() throws Exception {
    ComboPooledDataSource dataSource = new ComboPooledDataSource();
    dataSource.setDriverClass("com.mysql.jdbc.Driver");
    dataSource.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/TCC?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useSSL=false");
    dataSource.setUser("root");
    dataSource.setPassword("admin");
    return dataSource;
}
 
Example 13
Source File: MultiDatabaseTestCase.java    From Zebra with Apache License 2.0 5 votes vote down vote up
private DataSource createRealDataSource(String jdbcUrl, String user, String password, String driverClass)
		throws Exception {
	ComboPooledDataSource ds = new ComboPooledDataSource();
	ds.setJdbcUrl(jdbcUrl);
	ds.setUser(user);
	ds.setPassword(password);
	ds.setDriverClass(driverClass);
	return ds;
}
 
Example 14
Source File: MainConfigofProfile.java    From code with Apache License 2.0 5 votes vote down vote up
@Profile("prod")
@Bean("prodDataSource")
public DataSource dataSourceProd(@Value("${db.password}") String pwd) throws PropertyVetoException {
    ComboPooledDataSource dataSource = new ComboPooledDataSource();
    dataSource.setUser(user);
    dataSource.setPassword(pwd);
    dataSource.setDriverClass(driverClass);
    dataSource.setJdbcUrl("jdbc:mysql://localhost:3306/prod");
    return dataSource;
}
 
Example 15
Source File: MainConfigofProfile.java    From code with Apache License 2.0 5 votes vote down vote up
@Profile("dev")
@Bean("devDataSource")
public DataSource dataSourceDev(@Value("${db.password}") String pwd) throws PropertyVetoException {
    ComboPooledDataSource dataSource = new ComboPooledDataSource();
    dataSource.setUser(user);
    dataSource.setPassword(pwd);
    dataSource.setDriverClass(driverClass);
    dataSource.setJdbcUrl("jdbc:mysql://localhost:3306/dev");
    return dataSource;
}
 
Example 16
Source File: ConnectionPoolManager.java    From ezScrum with GNU General Public License v2.0 5 votes vote down vote up
private DataSource createDataSource(String driverClass, String url, String account, String password) {
	ComboPooledDataSource dataSource = new ComboPooledDataSource();
	try {
		dataSource.setDriverClass(driverClass);
		dataSource.setJdbcUrl(url);
		dataSource.setUser(account);
		dataSource.setPassword(password);

		dataSource.setMinPoolSize(10);
		dataSource.setMaxPoolSize(35);
		dataSource.setAcquireIncrement(0);
		dataSource.setMaxStatements(0);
		
		/** 最大允許的閒置時間(秒) */
		dataSource.setMaxIdleTime(300);
		/** 對閒置的連線進行Query測試設置(秒) */
		dataSource.setIdleConnectionTestPeriod(1800);
		
		/** Checkin connection時不檢查連線是否有效 */
		dataSource.setTestConnectionOnCheckin(false);
		/** Checkout connection時檢查連線的有效性*/
		dataSource.setTestConnectionOnCheckout(true);
		/** 進行test時使用的 Query設定*/
		dataSource.setPreferredTestQuery("SELECT 1;");
		/** Connection的最大有效時數(秒)*/
		dataSource.setMaxConnectionAge(28800);
		/** Connection checkout 之後的有效時數(毫秒)*/
		dataSource.setCheckoutTimeout(28800000);
	} catch (PropertyVetoException e) {
		e.printStackTrace();
	}
	mPoolMap.put(url, dataSource);
	return dataSource;
}
 
Example 17
Source File: C3P0DataSourceProvider.java    From vertx-jdbc-client with Apache License 2.0 4 votes vote down vote up
@Override
public DataSource getDataSource(JsonObject config) throws SQLException {
  String url = config.getString("url");
  if (url == null) throw new NullPointerException("url cannot be null");
  String driverClass = config.getString("driver_class");
  String user = config.getString("user");
  String password = config.getString("password");
  Integer maxPoolSize = config.getInteger("max_pool_size");
  Integer initialPoolSize = config.getInteger("initial_pool_size");
  Integer minPoolSize = config.getInteger("min_pool_size");
  Integer maxStatements = config.getInteger("max_statements");
  Integer maxStatementsPerConnection = config.getInteger("max_statements_per_connection");
  Integer maxIdleTime = config.getInteger("max_idle_time");
  Integer acquireRetryAttempts = config.getInteger("acquire_retry_attempts");
  Integer acquireRetryDelay = config.getInteger("acquire_retry_delay");
  Boolean breakAfterAcquireFailure = config.getBoolean("break_after_acquire_failure");

  // If you want to configure any other C3P0 properties you can add a file c3p0.properties to the classpath
  ComboPooledDataSource cpds = new ComboPooledDataSource();
  cpds.setJdbcUrl(url);
  if (driverClass != null) {
    try {
      cpds.setDriverClass(driverClass);
    } catch (PropertyVetoException e) {
      throw new IllegalArgumentException(e);
    }
  }
  if (user != null) {
    cpds.setUser(user);
  }
  if (password != null) {
    cpds.setPassword(password);
  }
  if (maxPoolSize != null) {
    cpds.setMaxPoolSize(maxPoolSize);
  }
  if (minPoolSize != null) {
    cpds.setMinPoolSize(minPoolSize);
  }
  if (initialPoolSize != null) {
    cpds.setInitialPoolSize(initialPoolSize);
  }
  if (maxStatements != null) {
    cpds.setMaxStatements(maxStatements);
  }
  if (maxStatementsPerConnection != null) {
    cpds.setMaxStatementsPerConnection(maxStatementsPerConnection);
  }
  if (maxIdleTime != null) {
    cpds.setMaxIdleTime(maxIdleTime);
  }
  if(acquireRetryAttempts != null){
    cpds.setAcquireRetryAttempts(acquireRetryAttempts);
  }
  if(acquireRetryDelay != null){
    cpds.setAcquireRetryDelay(acquireRetryDelay);
  }
  if(breakAfterAcquireFailure != null){
    cpds.setBreakAfterAcquireFailure(breakAfterAcquireFailure);
  }
  return cpds;
}
 
Example 18
Source File: IdServiceFactoryBean.java    From vesta-id-generator with Apache License 2.0 4 votes vote down vote up
private IdService constructDbIdService(String dbUrl, String dbName,
                                       String dbUser, String dbPassword) {
    log.info(
            "Construct Db IdService dbUrl {} dbName {} dbUser {} dbPassword {}",
            dbUrl, dbName, dbUser, dbPassword);

    ComboPooledDataSource comboPooledDataSource = new ComboPooledDataSource();

    String jdbcDriver = "com.mysql.jdbc.Driver";
    try {
        comboPooledDataSource.setDriverClass(jdbcDriver);
    } catch (PropertyVetoException e) {
        log.error("Wrong JDBC driver {}", jdbcDriver);
        log.error("Wrong JDBC driver error: ", e);
        throw new IllegalStateException("Wrong JDBC driver ", e);
    }

    comboPooledDataSource.setMinPoolSize(5);
    comboPooledDataSource.setMaxPoolSize(30);
    comboPooledDataSource.setIdleConnectionTestPeriod(20);
    comboPooledDataSource.setMaxIdleTime(25);
    comboPooledDataSource.setBreakAfterAcquireFailure(false);
    comboPooledDataSource.setCheckoutTimeout(3000);
    comboPooledDataSource.setAcquireRetryAttempts(50);
    comboPooledDataSource.setAcquireRetryDelay(1000);

    String url = String
            .format("jdbc:mysql://%s/%s?useUnicode=true&amp;characterEncoding=UTF-8&amp;autoReconnect=true",
                    dbUrl, dbName);

    comboPooledDataSource.setJdbcUrl(url);
    comboPooledDataSource.setUser(dbUser);
    comboPooledDataSource.setPassword(dbPassword);

    JdbcTemplate jdbcTemplate = new JdbcTemplate();
    jdbcTemplate.setLazyInit(false);
    jdbcTemplate.setDataSource(comboPooledDataSource);

    DbMachineIdProvider dbMachineIdProvider = new DbMachineIdProvider();
    dbMachineIdProvider.setJdbcTemplate(jdbcTemplate);
    dbMachineIdProvider.init();

    IdServiceImpl idServiceImpl = new IdServiceImpl();
    idServiceImpl.setMachineIdProvider(dbMachineIdProvider);
    if (genMethod != -1)
        idServiceImpl.setGenMethod(genMethod);
    if (type != -1)
        idServiceImpl.setType(type);
    if (version != -1)
        idServiceImpl.setVersion(version);
    idServiceImpl.init();

    return idServiceImpl;
}
 
Example 19
Source File: PoolingConnectionProvider.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create the underlying C3PO ComboPooledDataSource with the 
 * default supported properties.
 * @throws SchedulerException 
 */
private void initialize(
    String dbDriver, 
    String dbURL, 
    String dbUser,
    String dbPassword, 
    int maxConnections, 
    int maxStatementsPerConnection, 
    String dbValidationQuery,
    boolean validateOnCheckout,
    int idleValidationSeconds,
    int maxIdleSeconds) throws SQLException, SchedulerException {
    if (dbURL == null) {
        throw new SQLException(
            "DBPool could not be created: DB URL cannot be null");
    }
    
    if (dbDriver == null) {
        throw new SQLException(
            "DBPool '" + dbURL + "' could not be created: " +
            "DB driver class name cannot be null!");
    }
    
    if (maxConnections < 0) {
        throw new SQLException(
            "DBPool '" + dbURL + "' could not be created: " + 
            "Max connections must be greater than zero!");
    }

    
    datasource = new ComboPooledDataSource(); 
    try {
        datasource.setDriverClass(dbDriver);
    } catch (PropertyVetoException e) {
        throw new SchedulerException("Problem setting driver class name on datasource: " + e.getMessage(), e);
    }  
    datasource.setJdbcUrl(dbURL); 
    datasource.setUser(dbUser); 
    datasource.setPassword(dbPassword);
    datasource.setMaxPoolSize(maxConnections);
    datasource.setMinPoolSize(1);
    datasource.setMaxIdleTime(maxIdleSeconds);
    datasource.setMaxStatementsPerConnection(maxStatementsPerConnection);
    
    if (dbValidationQuery != null) {
        datasource.setPreferredTestQuery(dbValidationQuery);
        if(!validateOnCheckout)
            datasource.setTestConnectionOnCheckin(true);
        else
            datasource.setTestConnectionOnCheckout(true);
        datasource.setIdleConnectionTestPeriod(idleValidationSeconds);
    }
}
 
Example 20
Source File: DefaultDataSourceManager.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private List<DataSource> getReadOnlyDataSources()
{
    String mainUser = config.getProperty( ConfigurationKey.CONNECTION_USERNAME );
    String mainPassword = config.getProperty( ConfigurationKey.CONNECTION_PASSWORD );
    String driverClass = config.getProperty( CONNECTION_DRIVER_CLASS );
    String maxPoolSize = config.getPropertyOrDefault( CONNECTION_POOL_MAX_SIZE, DEFAULT_POOL_SIZE );

    Properties props = config.getProperties();

    List<DataSource> dataSources = new ArrayList<>();

    for ( int i = 1; i <= MAX_READ_REPLICAS; i++ )
    {
        String jdbcUrl = props.getProperty( String.format( FORMAT_CONNECTION_URL, i ) );
        String user = props.getProperty( String.format( FORMAT_CONNECTION_USERNAME, i ) );
        String password = props.getProperty( String.format( FORMAT_CONNECTION_PASSWORD, i ) );

        user = StringUtils.defaultIfEmpty( user, mainUser );
        password = StringUtils.defaultIfEmpty( password, mainPassword );

        if ( ObjectUtils.allNonNull( jdbcUrl, user, password ) )
        {
            try
            {
                ComboPooledDataSource ds = new ComboPooledDataSource();

                ds.setDriverClass( driverClass );
                ds.setJdbcUrl( jdbcUrl );
                ds.setUser( user );
                ds.setPassword( password );
                ds.setMaxPoolSize( Integer.parseInt( maxPoolSize ) );
                ds.setAcquireIncrement( VAL_ACQUIRE_INCREMENT );
                ds.setMaxIdleTime( VAL_MAX_IDLE_TIME );

                dataSources.add( ds );

                log.info( String.format( "Found read replica, index: '%d', connection URL: '%s''", i, jdbcUrl ) );

                testConnection( ds );
            }
            catch ( PropertyVetoException ex )
            {
                throw new IllegalArgumentException( "Invalid configuration of read replica: " + jdbcUrl, ex );
            }
        }
    }

    log.info( "Read only configuration initialized, read replicas found: " + dataSources.size() );

    return dataSources;
}