ds.setMinIdle( Integer.valueOf( value ) );
private JdbcPushDownConnectionManager(KylinConfig config) throws ClassNotFoundException { dataSource = new BasicDataSource(); Class.forName(config.getJdbcDriverClass()); dataSource.setDriverClassName(config.getJdbcDriverClass()); dataSource.setUrl(config.getJdbcUrl()); dataSource.setUsername(config.getJdbcUsername()); dataSource.setPassword(config.getJdbcPassword()); dataSource.setMaxActive(config.getPoolMaxTotal()); dataSource.setMaxIdle(config.getPoolMaxIdle()); dataSource.setMinIdle(config.getPoolMinIdle()); // Default settings dataSource.setTestOnBorrow(true); dataSource.setValidationQuery("select 1"); dataSource.setRemoveAbandoned(true); dataSource.setRemoveAbandonedTimeout(300); }
/** * Default constructor method. * @param config Basic configuration of JDBC source, such as driver name, URL, username, password. * @throws Exception If datasource cannot be connected. */ protected AbstractJdbcAdaptor(AdaptorConfig config) throws ClassNotFoundException { this.config = config; this.dataSourceDef = DataSourceDefProvider.getInstance().getById(config.datasourceId); dataSource = new BasicDataSource(); Class.forName(config.driver); dataSource.setDriverClassName(config.driver); dataSource.setUrl(config.url); dataSource.setUsername(config.username); dataSource.setPassword(config.password); dataSource.setMaxActive(config.poolMaxTotal); dataSource.setMaxIdle(config.poolMaxIdle); dataSource.setMinIdle(config.poolMinIdle); // Default settings dataSource.setTestOnBorrow(true); dataSource.setValidationQuery(getSourceValidationSql()); dataSource.setRemoveAbandoned(true); dataSource.setRemoveAbandonedTimeout(300); DataSourceDefProvider provider = DataSourceDefProvider.getInstance(); DataSourceDef jdbcDs = provider.getById(getDataSourceId()); configurer = new DefaultConfiguer(this, jdbcDs); }
@Override public synchronized void setMinIdle(int minIdle) { delegate.setMinIdle(minIdle); }
/** * Creates a data source by reading properties from a file called 'db.properties', located * paralell to the test setup instance. */ protected DataSource createDataSource() throws IOException { Properties db = fixture; BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(db.getProperty("driver")); dataSource.setUrl(db.getProperty("url")); if (db.containsKey("user")) { dataSource.setUsername(db.getProperty("user")); } else if (db.containsKey("username")) { dataSource.setUsername(db.getProperty("username")); } if (db.containsKey("password")) { dataSource.setPassword(db.getProperty("password")); } dataSource.setPoolPreparedStatements(true); dataSource.setAccessToUnderlyingConnectionAllowed(true); dataSource.setMinIdle(1); dataSource.setMaxActive(4); // if we cannot get a connection within 5 seconds give up dataSource.setMaxWait(5000); initializeDataSource(dataSource, db); // return a closeable data source (DisposableDataSource interface) // so that the connection pool will be tore down on datastore dispose return new DBCPDataSource(dataSource); }
/** * Set the minimum number of idle connections in the pool. * * @param minIdle the new value for minIdle. * @see org.apache.commons.pool.impl.GenericObjectPool#setMinIdle(int) */ @Managed(description = "The minimum number of idle connections in the pool.") public synchronized void setMinIdle(int minIdle) { super.setMinIdle(minIdle); }
dbcpDataSource.setInitialSize(getIntProperty(config, "initialPoolSize", 5)); dbcpDataSource.setMaxActive(getIntProperty(config, "maxPoolSize", 30)); dbcpDataSource.setMinIdle(getIntProperty(config, "minPoolSize", 5)); dbcpDataSource.setMaxIdle(getIntProperty(config, "maxPoolSize", 20)); dbcpDataSource.setMaxWait(getIntProperty(config, "checkoutTimeout", 1000));
dataSource.setMinIdle(minIdle);
@ManagedAttribute @Description("Set the minimum number of active connections that can remain idle in the pool, without extra ones" + " being created when the evictor runs, or 0 to create none.") public void setMinIdle(final int min) { ds.setMinIdle(min); }
dataSource.setMinIdle(minConn);
/** * Prepares a simple data source for the embedded H2 * * @param cacheDirFinder * @return * @throws ConfigurationException */ private DataSource getH2DataSource(DefaultStorageFinder cacheDirFinder) throws ConfigurationException { File storeDirectory = new File(cacheDirFinder.getDefaultPath(), "diskquota_page_store_h2"); storeDirectory.mkdirs(); BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName("org.h2.Driver"); String database = new File(storeDirectory, "diskquota").getAbsolutePath(); dataSource.setUrl("jdbc:h2:" + database); dataSource.setUsername("sa"); dataSource.setPoolPreparedStatements(true); dataSource.setAccessToUnderlyingConnectionAllowed(true); dataSource.setMinIdle(1); dataSource.setMaxActive(-1); // boundless dataSource.setMaxWait(5000); return dataSource; }
private DataSource buildDataSource(DatabaseConfiguration config) { BasicDataSource basicDataSource = new BasicDataSource(); basicDataSource.setUrl(config.getDbUrl().trim()); basicDataSource.setDriverClassName(config.getDriverName().trim()); basicDataSource.setUsername(config.getUserName().trim()); basicDataSource.setPassword(config.getPassword().trim()); basicDataSource.setMaxActive(config.getMaxActive()); basicDataSource.setMaxIdle(config.getMaxIdle()); basicDataSource.setMaxWait(config.getMaxWait()); basicDataSource.setMinIdle(config.getMinIdle()); basicDataSource.setValidationQuery(config.getValidationQuery()); return basicDataSource; }
private static DataSource createFromJdbcUrl(Class<? extends Driver> driverClass, String url, Credential credential, int numThreads, ImmutableList<String> initSqls, Properties extraConnectionProperties) { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(driverClass.getName()); dataSource.setUrl(url); dataSource.setUsername(credential.getUsername()); dataSource.setPassword(credential.getPassword()); // connection pool settings dataSource.setInitialSize(numThreads); dataSource.setMaxActive(numThreads); // keep the connections open if possible; only close them via the removeAbandonedTimeout feature dataSource.setMaxIdle(numThreads); dataSource.setMinIdle(0); dataSource.setRemoveAbandonedTimeout(300); dataSource.setConnectionInitSqls(initSqls.castToList()); if (extraConnectionProperties != null) { for (String key : extraConnectionProperties.stringPropertyNames()) { dataSource.addConnectionProperty(key, extraConnectionProperties.getProperty(key)); } } return dataSource; } }
private static DataSource createFromJdbcUrl(Class<? extends Driver> driverClass, String url, Credential credential, int numThreads, ImmutableList<String> initSqls, Properties extraConnectionProperties) { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(driverClass.getName()); dataSource.setUrl(url); dataSource.setUsername(credential.getUsername()); dataSource.setPassword(credential.getPassword()); // connection pool settings dataSource.setInitialSize(numThreads); dataSource.setMaxActive(numThreads); // keep the connections open if possible; only close them via the removeAbandonedTimeout feature dataSource.setMaxIdle(numThreads); dataSource.setMinIdle(0); dataSource.setRemoveAbandonedTimeout(300); dataSource.setConnectionInitSqls(initSqls.castToList()); if (extraConnectionProperties != null) { for (String key : extraConnectionProperties.stringPropertyNames()) { dataSource.addConnectionProperty(key, extraConnectionProperties.getProperty(key)); } } return dataSource; } }
protected void setupDbcp() { org.apache.commons.dbcp.BasicDataSource ds = new org.apache.commons.dbcp.BasicDataSource(); ds.setUrl(jdbcUrl); ds.setUsername("brettw"); ds.setPassword(""); ds.setInitialSize(MIN_POOL_SIZE); ds.setMinIdle(MIN_POOL_SIZE); ds.setMaxIdle(maxPoolSize); ds.setMaxActive(maxPoolSize); ds.setDefaultAutoCommit(false); ds.setTestOnBorrow(true); ds.setValidationQuery("SELECT 1"); DS = ds; }
private void setupDataSource() { setDerbyPaths(); dataSource = new BasicDataSource(); dataSource.setDriverClassName(databaseConfiguration.getDriverClassName()); System.setProperty("hibernate.dialect", databaseConfiguration.getHibernateDialect()); dataSource.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED); dataSource.setMaxActive(databaseConfiguration.getPoolMaxActive()); dataSource.setMinIdle(databaseConfiguration.getPoolMinIdle()); dataSource.setMaxIdle(databaseConfiguration.getPoolMaxIdle()); dataSource.setDefaultAutoCommit(true); dataSource.setInitialSize(databaseConfiguration.getPoolMinIdle()); //Derby blows up if the username of password is empty (even an empty string thats not null). if (databaseConfiguration.getUsername()!=null && databaseConfiguration.getUsername().length()>=1) dataSource.setUsername(databaseConfiguration.getUsername()); if (databaseConfiguration.getPassword()!=null && databaseConfiguration.getPassword().length()>=1) dataSource.setPassword(databaseConfiguration.getPassword()); dataSource.setUrl(databaseConfiguration.getJDBCUri()); }
protected BasicDataSource getDataSource() throws IOException, SQLException { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(fixtureRule.getFixture().getProperty("driver")); dataSource.setUrl(fixtureRule.getFixture().getProperty("url")); dataSource.setUsername(fixtureRule.getFixture().getProperty("username")); dataSource.setPassword(fixtureRule.getFixture().getProperty("password")); dataSource.setPoolPreparedStatements(true); dataSource.setAccessToUnderlyingConnectionAllowed(true); dataSource.setMinIdle(1); dataSource.setMaxActive(4); // if we cannot get a connection within 5 seconds give up dataSource.setMaxWait(5000); cleanupDatabase(dataSource); return dataSource; }
private JdbcPushDownConnectionManager(KylinConfig config) throws ClassNotFoundException { dataSource = new BasicDataSource(); Class.forName(config.getJdbcDriverClass()); dataSource.setDriverClassName(config.getJdbcDriverClass()); dataSource.setUrl(config.getJdbcUrl()); dataSource.setUsername(config.getJdbcUsername()); dataSource.setPassword(config.getJdbcPassword()); dataSource.setMaxActive(config.getPoolMaxTotal()); dataSource.setMaxIdle(config.getPoolMaxIdle()); dataSource.setMinIdle(config.getPoolMinIdle()); // Default settings dataSource.setTestOnBorrow(true); dataSource.setValidationQuery("select 1"); dataSource.setRemoveAbandoned(true); dataSource.setRemoveAbandonedTimeout(300); }
/** * Default constructor method. * @param config Basic configuration of JDBC source, such as driver name, URL, username, password. * @throws Exception If datasource cannot be connected. */ protected AbstractJdbcAdaptor(AdaptorConfig config) throws ClassNotFoundException { this.config = config; this.dataSourceDef = DataSourceDefProvider.getInstance().getById(config.datasourceId); dataSource = new BasicDataSource(); Class.forName(config.driver); dataSource.setDriverClassName(config.driver); dataSource.setUrl(config.url); dataSource.setUsername(config.username); dataSource.setPassword(config.password); dataSource.setMaxActive(config.poolMaxTotal); dataSource.setMaxIdle(config.poolMaxIdle); dataSource.setMinIdle(config.poolMinIdle); // Default settings dataSource.setTestOnBorrow(true); dataSource.setValidationQuery(getSourceValidationSql()); dataSource.setRemoveAbandoned(true); dataSource.setRemoveAbandonedTimeout(300); DataSourceDefProvider provider = DataSourceDefProvider.getInstance(); DataSourceDef jdbcDs = provider.getById(getDataSourceId()); configurer = new DefaultConfiguer(this, jdbcDs); }
@Override protected BasicDataSource setupDataSourcePool( DataSourceConfigurationValue config ) throws Exception { BasicDataSource pool = new BasicDataSource(); Class.forName( config.driver().get() ); pool.setDriverClassName( config.driver().get() ); pool.setUrl( config.url().get() ); if ( !config.username().get().equals( "" ) ) { pool.setUsername( config.username().get() ); pool.setPassword( config.password().get() ); } if ( config.minPoolSize().get() != null ) { pool.setMinIdle( config.minPoolSize().get() ); } if ( config.maxPoolSize().get() != null ) { pool.setMaxActive( config.maxPoolSize().get() ); } if ( config.loginTimeoutSeconds().get() != null ) { pool.setLoginTimeout( config.loginTimeoutSeconds().get() ); } if ( config.maxConnectionAgeSeconds().get() != null ) { pool.setMinEvictableIdleTimeMillis( config.maxConnectionAgeSeconds().get() * 1000 ); } if ( config.validationQuery().get() != null ) { pool.setValidationQuery( config.validationQuery().get() ); } return pool; }