List of usage examples for org.apache.commons.dbcp BasicDataSource setTestOnBorrow
public synchronized void setTestOnBorrow(boolean testOnBorrow)
From source file:org.plista.kornakapi.core.storage.MySqlStorage.java
public MySqlStorage(StorageConfiguration storageConf, String label, BasicDataSource dataSource) { dataSource.setDriverClassName(storageConf.getJdbcDriverClass()); dataSource.setUrl(storageConf.getJdbcUrl()); dataSource.setUsername(storageConf.getUsername()); dataSource.setPassword(storageConf.getPassword()); //TODO should be made configurable dataSource.setMaxActive(10);/*from ww w . ja va2 s . com*/ dataSource.setMinIdle(5); dataSource.setInitialSize(5); dataSource.setValidationQuery("SELECT 1;"); dataSource.setTestOnBorrow(false); dataSource.setTestOnReturn(false); dataSource.setTestWhileIdle(true); dataSource.setTimeBetweenEvictionRunsMillis(5000); dataModel = new LabeledMySQLJDBCDataModel(dataSource, "taste_preferences", "user_id", "item_id", "preference", "timestamp", "taste_candidates", "label", label); this.dataSource = dataSource; this.timeWindow = storageConf.getTimeWindow(); if (timeWindow % 6 != 0 || timeWindow == 0) { timeWindow = 24; } }
From source file:org.shelloid.vpt.rms.util.Platform.java
private BasicDataSource configDbPool() { BasicDataSource ds = new BasicDataSource(); ds.setTestOnBorrow(true); ds.setValidationQuery("SELECT 1"); ds.setDriverClassName(get(Configurations.ConfigParams.JDBC_DRIVER)); ds.setUrl(get(Configurations.ConfigParams.JDBC_URL)); ds.setUsername(get(Configurations.ConfigParams.JDBC_USERNAME)); ds.setPassword(get(Configurations.ConfigParams.JDBC_PASSWORD)); ds.setMaxActive(Integer.parseInt(get(Configurations.ConfigParams.JDBC_MAX_ACTIVE))); ds.setMaxIdle(Integer.parseInt(get(Configurations.ConfigParams.JDBC_MIN_IDLE))); return ds;/*ww w . j a va 2 s . c o m*/ }
From source file:se.unlogic.hierarchy.core.utils.DBCPUtils.java
public static BasicDataSource createConnectionPool(DataSourceDescriptor dataSourceDescriptor) { BasicDataSource basicDataSource = new BasicDataSource(); basicDataSource.setDriverClassName(dataSourceDescriptor.getDriver()); basicDataSource.setUsername(dataSourceDescriptor.getUsername()); basicDataSource.setPassword(dataSourceDescriptor.getPassword()); basicDataSource.setUrl(dataSourceDescriptor.getUrl()); basicDataSource.setDefaultCatalog(dataSourceDescriptor.getDefaultCatalog()); basicDataSource.setLogAbandoned(dataSourceDescriptor.logAbandoned()); basicDataSource.setRemoveAbandoned(dataSourceDescriptor.removeAbandoned()); if (dataSourceDescriptor.getRemoveTimeout() != null) { basicDataSource.setRemoveAbandonedTimeout(dataSourceDescriptor.getRemoveTimeout()); }// www . j av a2s . c om basicDataSource.setTestOnBorrow(dataSourceDescriptor.testOnBorrow()); basicDataSource.setValidationQuery(dataSourceDescriptor.getValidationQuery()); basicDataSource.setMaxWait(dataSourceDescriptor.getMaxWait()); basicDataSource.setMaxActive(dataSourceDescriptor.getMaxActive()); basicDataSource.setMaxIdle(dataSourceDescriptor.getMaxIdle()); basicDataSource.setMinIdle(dataSourceDescriptor.getMinIdle()); return basicDataSource; }