当前位置: 首页>>代码示例>>Java>>正文


Java BasicDataSource.setInitialSize方法代码示例

本文整理汇总了Java中org.apache.commons.dbcp2.BasicDataSource.setInitialSize方法的典型用法代码示例。如果您正苦于以下问题:Java BasicDataSource.setInitialSize方法的具体用法?Java BasicDataSource.setInitialSize怎么用?Java BasicDataSource.setInitialSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.dbcp2.BasicDataSource的用法示例。


在下文中一共展示了BasicDataSource.setInitialSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getBasicDataSource

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
private static BasicDataSource getBasicDataSource(DatasourceConfiguration configuration) {
    BasicDataSource dbcpDataSource = new BasicDataSource();
    dbcpDataSource.setDriverClassName(configuration.getDriverClassname());
    dbcpDataSource.setUrl(configuration.getUrl());
    dbcpDataSource.setUsername(configuration.getUser());
    dbcpDataSource.setPassword(configuration.getPassword());

    // Enable statement caching (Optional)
    dbcpDataSource.setPoolPreparedStatements(true);
    dbcpDataSource.setValidationQuery("Select 1 ");
    dbcpDataSource.setMaxOpenPreparedStatements(50);
    dbcpDataSource.setLifo(true);
    dbcpDataSource.setMaxTotal(10);
    dbcpDataSource.setInitialSize(2);
    return dbcpDataSource;
}
 
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:17,代码来源:DBCPSqlDataStore.java

示例2: invokeGetDataSource

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
public DataSource invokeGetDataSource() {
	BasicDataSource bds = new BasicDataSource();
	bds.setDriverClassName("com.mysql.jdbc.Driver");
	bds.setUrl("jdbc:mysql://127.0.0.1:3306/inst02");
	bds.setUsername("root");
	bds.setPassword("123456");
	bds.setMaxTotal(50);
	bds.setInitialSize(20);
	bds.setMaxWaitMillis(60000);
	bds.setMinIdle(6);
	bds.setLogAbandoned(true);
	bds.setRemoveAbandonedOnBorrow(true);
	bds.setRemoveAbandonedOnMaintenance(true);
	bds.setRemoveAbandonedTimeout(1800);
	bds.setTestWhileIdle(true);
	bds.setTestOnBorrow(false);
	bds.setTestOnReturn(false);
	bds.setValidationQuery("select 'x' ");
	bds.setValidationQueryTimeout(1);
	bds.setTimeBetweenEvictionRunsMillis(30000);
	bds.setNumTestsPerEvictionRun(20);
	return bds;
}
 
开发者ID:liuyangming,项目名称:ByteTCC-sample,代码行数:24,代码来源:ConsumerConfig.java

示例3: invokeGetDataSource

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
public DataSource invokeGetDataSource() {
	BasicDataSource bds = new BasicDataSource();
	bds.setDriverClassName("com.mysql.jdbc.Driver");
	bds.setUrl("jdbc:mysql://127.0.0.1:3306/inst01");
	bds.setUsername("root");
	bds.setPassword("123456");
	bds.setMaxTotal(50);
	bds.setInitialSize(20);
	bds.setMaxWaitMillis(60000);
	bds.setMinIdle(6);
	bds.setLogAbandoned(true);
	bds.setRemoveAbandonedOnBorrow(true);
	bds.setRemoveAbandonedOnMaintenance(true);
	bds.setRemoveAbandonedTimeout(1800);
	bds.setTestWhileIdle(true);
	bds.setTestOnBorrow(false);
	bds.setTestOnReturn(false);
	bds.setValidationQuery("select 'x' ");
	bds.setValidationQueryTimeout(1);
	bds.setTimeBetweenEvictionRunsMillis(30000);
	bds.setNumTestsPerEvictionRun(20);
	return bds;
}
 
开发者ID:liuyangming,项目名称:ByteTCC-sample,代码行数:24,代码来源:ProviderConfig.java

示例4: dbcp

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
@SneakyThrows
private static CloseableDatasource dbcp(Config config) {
    int threads = config.getInt("threads");
    BasicDataSource dataSource = new BasicDataSource();

    dataSource.setDriverClassName(config.getString("driver"));
    dataSource.setUrl(config.getString("url"));

    dataSource.setUsername(config.getString("user"));
    dataSource.setPassword(config.getString("pwd"));

    dataSource.setInitialSize(threads);

    dataSource.setMinEvictableIdleTimeMillis(120 * 1000);//seconds

    DBCPCloseableDataSource ds = new DBCPCloseableDataSource(dataSource);
    return ds;
}
 
开发者ID:jamescross91,项目名称:shyft-extractor,代码行数:19,代码来源:DatasourceBuilder.java

示例5: newDataSource

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
private static BasicDataSource newDataSource(String id, String driver, String db, String user, String pswd, int initial, int max)
{
  LOG.info("Initializing a fresh pool for Id=" + id + ", DB=" + db + ", User=" + user + ", and Pswd=Shhhhhhh!");
  BasicDataSource BDS = new BasicDataSource();
  BDS.setDriverClassName(driver);
  BDS.setUrl(db);
  if (TextUtil.isNullOrEmpty(pswd) == false && TextUtil.isNullOrEmpty(user) == false)
    {
      BDS.setUsername(user);
      BDS.setPassword(pswd);
    }
  BDS.setInitialSize(initial);
  BDS.setMaxTotal(max);
  BDS.setDefaultAutoCommit(false);
  BDS.setDefaultTransactionIsolation(java.sql.Connection.TRANSACTION_READ_COMMITTED);
  BDS.setDefaultQueryTimeout(20000);
  return BDS;
}
 
开发者ID:CapsicoHealth,项目名称:Tilda,代码行数:19,代码来源:ConnectionPool.java

示例6: init

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
@PostConstruct
/**
 * Creates security data-source to be used with the sample DB 
 */
public void init() {
       securityDataSource = new BasicDataSource();
       securityDataSource.setDriverClassName(com.mysql.jdbc.Driver.class.getName());
       securityDataSource.setUrl("jdbc:mysql://localhost:3306/java_one_2014");
       securityDataSource.setUsername("java_one");
       securityDataSource.setPassword("");
	securityDataSource.setInitialSize(5);
       securityDataSource.setMaxTotal(30);
       securityDataSource.setMaxIdle(15);
       securityDataSource.setMaxWaitMillis(3000);
       securityDataSource.setLogAbandoned(true);
       securityDataSource.setTestWhileIdle(true);
       securityDataSource.setTestOnBorrow(true);
       securityDataSource.setValidationQuery("select 1");
}
 
开发者ID:ishaigor,项目名称:rest-retro-sample,代码行数:20,代码来源:PersistenceConfiguration.java

示例7: wrap

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
@Override
public DataSource wrap(final ReportDataSource rptDs) {
    try {
        final BasicDataSource dataSource = new BasicDataSource();
        dataSource.setDriverClassName(rptDs.getDriverClass());
        dataSource.setUrl(rptDs.getJdbcUrl());
        dataSource.setUsername(rptDs.getUser());
        dataSource.setPassword(rptDs.getPassword());
        dataSource.setInitialSize(MapUtils.getInteger(rptDs.getOptions(), "initialSize", 3));
        dataSource.setMaxIdle(MapUtils.getInteger(rptDs.getOptions(), "maxIdle", 20));
        dataSource.setMinIdle(MapUtils.getInteger(rptDs.getOptions(), "minIdle", 1));
        dataSource.setLogAbandoned(MapUtils.getBoolean(rptDs.getOptions(), "logAbandoned", true));
        dataSource.setRemoveAbandonedTimeout(
            MapUtils.getInteger(rptDs.getOptions(), "removeAbandonedTimeout", 180));
        dataSource.setMaxWaitMillis(MapUtils.getInteger(rptDs.getOptions(), "maxWait", 1000));
        return dataSource;
    } catch (final Exception ex) {
        throw new RuntimeException("C3p0DataSourcePool Create Error", ex);
    }
}
 
开发者ID:xianrendzw,项目名称:EasyReport,代码行数:21,代码来源:DBCP2DataSourcePool.java

示例8: get

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
@Override
public DataSource get() throws PropertyVetoException {
    BasicDataSource ds = new org.apache.commons.dbcp2.BasicDataSource();
    ds.setDriverClassName("com.mysql.cj.jdbc.Driver");
    ds.setUsername("tully");
    ds.setPassword("tully");
    ds.setUrl("jdbc:mysql://localhost:3306/db_example");

    ds.setInitialSize(10);
    ds.setMaxTotal(20);

    return ds;
}
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_06,代码行数:14,代码来源:DBCPDataSourceFactory.java

示例9: getDataSource

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
@Bean(name = "dataSource")
public DataSource getDataSource(){
    BasicDataSource dataSource = new BasicDataSource();
    dataSource.setUrl("jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8&aut");
    dataSource.setUsername("root");
    dataSource.setPassword("");
    dataSource.setInitialSize(3);
    dataSource.setMinIdle(3);
    dataSource.setMaxIdle(5);
    dataSource.setMaxTotal(10);
    return dataSource;
}
 
开发者ID:easymall,项目名称:easymall,代码行数:13,代码来源:DataResourceConfig.java

示例10: initializeConnectionPool

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
private void initializeConnectionPool(BasicDataSource connectionPool, URI databaseUri) {
    final String dbUrl = "jdbc:postgresql://" + databaseUri.getHost() + databaseUri.getPath();

    if (databaseUri.getUserInfo() != null) {
        connectionPool.setUsername(databaseUri.getUserInfo().split(":")[0]);
        connectionPool.setPassword(databaseUri.getUserInfo().split(":")[1]);
    }
    connectionPool.setDriverClassName("org.postgresql.Driver");
    connectionPool.setUrl(dbUrl);
    connectionPool.setInitialSize(1);
}
 
开发者ID:bytefish,项目名称:FlinkExperiments,代码行数:12,代码来源:PooledConnectionFactory.java

示例11: initConnectionPool

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
private void initConnectionPool() {
    connectionPool = new BasicDataSource();
    connectionPool.setUsername(username);
    connectionPool.setPassword(password);
    connectionPool.setDriverClassName("org.postgresql.Driver");
    connectionPool.setUrl(url);
    connectionPool.setInitialSize(5);
}
 
开发者ID:stucco,项目名称:graph-db-connection,代码行数:9,代码来源:PostgresqlDBConnection.java

示例12: getDataSource

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
protected BasicDataSource getDataSource(String jdbcDriver, String jdbcUrl, String username, String password) {
    BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName(jdbcDriver);
    dataSource.setUsername(username);
    dataSource.setPassword(password);
    dataSource.setMaxIdle(5);
    dataSource.setMinIdle(1);
    dataSource.setMaxWaitMillis(5000);
    dataSource.setMaxTotal(40);
    dataSource.setInitialSize(10);
    dataSource.setUrl(jdbcUrl);
    return dataSource;
}
 
开发者ID:PkayJava,项目名称:MBaaS,代码行数:14,代码来源:DataSourceFactoryBean.java

示例13: createDataSource

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
public static DataSource createDataSource(String host, int port, String name, String user, String password) {
    BasicDataSource bds = new BasicDataSource();

    bds.setDriverClassName("com.mysql.jdbc.Driver");
    bds.setUrl(String.format("jdbc:mysql://%s:%d/%s", host, port, name));
    bds.setUsername(user);
    bds.setPassword(password);
    bds.setInitialSize(5);

    return bds;
}
 
开发者ID:simpleci,项目名称:simpleci,代码行数:12,代码来源:ConnectionUtils.java

示例14: buildDataSource

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
private DataSource buildDataSource() {
BasicDataSource connectionPool = new BasicDataSource();
connectionPool.setDriverClassName(env.getProperty("auth.providers.jdbc.driver"));
connectionPool.setUsername(env.getProperty("auth.providers.jdbc.username"));
connectionPool.setPassword(env.getProperty("auth.providers.jdbc.password"));
connectionPool.setUrl(env.getProperty("auth.providers.jdbc.url"));
connectionPool.setInitialSize(1);
return connectionPool;
   }
 
开发者ID:tomacla,项目名称:auth-token,代码行数:10,代码来源:SpringBootstrap.java

示例15: buildDataSource

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
private static DataSource buildDataSource() {
BasicDataSource connectionPool = new BasicDataSource();
connectionPool.setDriverClassName("org.hsqldb.jdbc.JDBCDriver");
connectionPool.setUsername("sa");
connectionPool.setPassword("");
connectionPool.setUrl("jdbc:hsqldb:mem:testdb");
connectionPool.setInitialSize(1);
return connectionPool;
   }
 
开发者ID:tomacla,项目名称:auth-token,代码行数:10,代码来源:JdbcProviderTest.java


注:本文中的org.apache.commons.dbcp2.BasicDataSource.setInitialSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。