// see also org.mifosplatform.DataSourceProperties.setMifosDefaults()
final String jdbcUrl = tenant.databaseURL();
final PoolConfiguration poolConfiguration = new PoolProperties();
poolConfiguration.setDriverClassName("com.mysql.jdbc.Driver");
poolConfiguration.setName(tenant.getSchemaName() + "_pool");
poolConfiguration.setUrl(jdbcUrl);
poolConfiguration.setUsername(tenant.getSchemaUsername());
poolConfiguration.setPassword(tenant.getSchemaPassword());
poolConfiguration.setInitialSize(tenant.getInitialSize());
poolConfiguration.setTestOnBorrow(tenant.isTestOnBorrow());
poolConfiguration.setValidationQuery("SELECT 1");
poolConfiguration.setValidationInterval(tenant.getValidationInterval());
poolConfiguration.setRemoveAbandoned(tenant.isRemoveAbandoned());
poolConfiguration.setRemoveAbandonedTimeout(tenant.getRemoveAbandonedTimeout());
poolConfiguration.setLogAbandoned(tenant.isLogAbandoned());
poolConfiguration.setAbandonWhenPercentageFull(tenant.getAbandonWhenPercentageFull());
/**
* Vishwas- Do we need to enable the below properties and add
* ResetAbandonedTimer for long running batch Jobs?
**/
// poolConfiguration.setMaxActive(tenant.getMaxActive());
// poolConfiguration.setMinIdle(tenant.getMinIdle());
// poolConfiguration.setMaxIdle(tenant.getMaxIdle());
// poolConfiguration.setSuspectTimeout(tenant.getSuspectTimeout());
// poolConfiguration.setTimeBetweenEvictionRunsMillis(tenant.getTimeBetweenEvictionRunsMillis());
// poolConfiguration.setMinEvictableIdleTimeMillis(tenant.getMinEvictableIdleTimeMillis());
poolConfiguration.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;"
+ "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer;org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport");
return new org.apache.tomcat.jdbc.pool.DataSource(poolConfiguration);
}