當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。