@Inject public DataSourceProvider(@Named("dataSourceProperties") Properties properties) { this.basicDataSource = new BasicDataSource(); this.basicDataSource.setDriverClassName(properties.getProperty(CONN_DRIVER, DEFAULT_CONN_DRIVER)); this.basicDataSource.setUrl(properties.getProperty(CONN_URL)); if (properties.containsKey(USERNAME) && properties.containsKey(PASSWORD)) { this.basicDataSource.setUsername(properties.getProperty(USERNAME)); this.basicDataSource .setPassword(PasswordManager.getInstance(properties).readPassword(properties.getProperty(PASSWORD))); } if (properties.containsKey(MAX_IDLE_CONNS)) { this.basicDataSource.setMaxIdle(Integer.parseInt(properties.getProperty(MAX_IDLE_CONNS))); } if (properties.containsKey(MAX_ACTIVE_CONNS)) { this.basicDataSource.setMaxActive(Integer.parseInt(properties.getProperty(MAX_ACTIVE_CONNS))); } }
ds.setMaxIdle(Integer.parseInt(defaultIfNull(val, "50")));
ds.setMaxIdle( Integer.valueOf( value ) );
BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName("com.mysql.jdbc.Driver"); dataSource.setUsername("username"); dataSource.setPassword("password"); dataSource.setUrl("jdbc:mysql://<host>:<port>/<database>"); dataSource.setMaxActive(10); dataSource.setMaxIdle(5); dataSource.setInitialSize(5); dataSource.setValidationQuery("SELECT 1");
@PostConstruct public void init() { BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName(JDBC_DRIVER_NAME); ds.setUrl("jdbc:derby:" + NACOS_HOME + File.separator + DERBY_BASE_DIR + ";create=true"); ds.setUsername(USER_NAME); ds.setPassword(PASSWORD); ds.setInitialSize(20); ds.setMaxActive(30); ds.setMaxIdle(50); ds.setMaxWait(10000L); ds.setPoolPreparedStatements(true); ds.setTimeBetweenEvictionRunsMillis(TimeUnit.MINUTES .toMillis(10L)); ds.setTestWhileIdle(true); jt = new JdbcTemplate(); jt.setMaxRows(50000); jt.setQueryTimeout(5000); jt.setDataSource(ds); DataSourceTransactionManager tm = new DataSourceTransactionManager(); tjt = new TransactionTemplate(tm); tm.setDataSource(ds); tjt.setTimeout(5000); if (STANDALONE_MODE && !propertyUtil.isStandaloneUseMysql()) { reload(); } }
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); }
public DataSource createNewDataSource(Map params) throws IOException { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName((String) DRIVERCLASS.lookUp(params)); dataSource.setUrl((String) JDBC_URL.lookUp(params)); dataSource.setUsername((String) USERNAME.lookUp(params)); dataSource.setPassword((String) PASSWORD.lookUp(params)); dataSource.setAccessToUnderlyingConnectionAllowed(true); dataSource.setMaxActive(((Integer) MAXACTIVE.lookUp(params)).intValue()); dataSource.setMaxIdle(((Integer) MAXIDLE.lookUp(params)).intValue()); // check the data source is properly setup by trying to gather a connection out of it Connection conn = null; try { conn = dataSource.getConnection(); } catch (SQLException e) { throw new DataSourceException( "Connection pool improperly set up: " + e.getMessage(), e); } finally { // close the connection at once if (conn != null) try { conn.close(); } catch (SQLException e) { } } return dataSource; }
bds.setUrl(olap4jDriverConnectionString); bds.setPoolPreparedStatements(false); bds.setMaxIdle(maxPerUserConnectionCount); bds.setMaxActive(maxPerUserConnectionCount); bds.setMinEvictableIdleTimeMillis(
@Override public synchronized void setMaxIdle(int maxIdle) { delegate.setMaxIdle(maxIdle); }
/** * Set the maximum number of connections that can remain idle in the pool. * * @param maxIdle the new value for maxIdle. * @see #getMaxIdle() */ @Managed(description = "Set the maximum number of connections that can remain idle in the pool.") public synchronized void setMaxIdle(int maxIdle) { super.setMaxIdle(maxIdle); }
dbcpDataSource.setMaxActive(getIntProperty(config, "maxPoolSize", 30)); dbcpDataSource.setMinIdle(getIntProperty(config, "minPoolSize", 5)); dbcpDataSource.setMaxIdle(getIntProperty(config, "maxPoolSize", 20)); dbcpDataSource.setMaxWait(getIntProperty(config, "checkoutTimeout", 1000)); dbcpDataSource.setValidationQuery(getStringProperty(config, "preferredTestQuery", "SELECT 1"));
@ManagedAttribute @Description("Set the maximum number of connections that can remain idle in the pool, without extra ones being" + "destroyed, or negative for no limit.") public void setMaxIdle(final int max) { ds.setMaxIdle(max); }
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; }
BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName("com.mysql.jdbc.Driver"); dataSource.setUsername("username"); dataSource.setPassword("password"); dataSource.setUrl("jdbc:mysql://<host>:<port>/<database>"); dataSource.setMaxActive(50); dataSource.setMaxIdle(5); dataSource.setInitialSize(5); dataSource.setValidationQuery("SELECT 1");
@Override protected void initializeImpl(String propertyPrefix) { log.info("Initializing pooled connection manager"); dataSource = new BasicDataSource(); dataSource.setDriverClassName(getDriverClassName()); dataSource.setUrl(getUrl(propertyPrefix)); dataSource.setUsername(Common.envProps.getString(propertyPrefix + "db.username")); dataSource.setPassword(getDatabasePassword(propertyPrefix)); dataSource.setMaxActive(Common.envProps.getInt(propertyPrefix + "db.pool.maxActive", 10)); dataSource.setMaxIdle(Common.envProps.getInt(propertyPrefix + "db.pool.maxIdle", 10)); dataSource.setValidationQuery("SELECT 1"); dataSource.setTestOnBorrow(true); }
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()); }
private static DataSource setupDataSource() { BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName(getDriver()); ds.setUsername(getUser()); ds.setPassword(getPassword()); ds.setUrl(getConnectionString()); ds.setDefaultAutoCommit(false); ds.setInitialSize(4); ds.setMaxActive(60); ds.setMaxIdle(10); ds.setValidationQuery("/* ping */ SELECT 1");//config to validate against mysql ds.setValidationQueryTimeout(3); ds.setTestOnBorrow(true); ds.setTestOnReturn(true); return ds; }
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); }