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


Java BasicDataSource.setMaxTotal方法代码示例

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


在下文中一共展示了BasicDataSource.setMaxTotal方法的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: AbstractMysqlHandler

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
public AbstractMysqlHandler() throws Exception{
        shardCount = Integer.parseInt(System.getProperty(PROP_SHARD_CNT));
        for(int i=0; i<shardCount; i++){
            final BasicDataSource ds = new BasicDataSource();
            ds.setMaxTotal(1024);
            ds.setMaxIdle(1024);
            ds.setMinIdle(0);
            ds.setUrl(System.getProperty(String.format(PROP_SHARD_URL, i)));
            ds.setUsername(System.getProperty(String.format(PROP_SHARD_USERNAME, i)));
            ds.setPassword(System.getProperty(String.format(PROP_SHARD_PASSWORD, i)));
            dataSourceList.add(ds);
        }
        
//        final ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
//        scriptEngine = scriptEngineManager.getEngineByName(SCRIPT_ENGINE_NAME);
//        scriptEngine.eval(System.getProperty(PROP_SCRIPT));
        
    }
 
开发者ID:kakao,项目名称:adt,代码行数:19,代码来源:AbstractMysqlHandler.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: initialize

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
public static void initialize(String driverName, String driverUrl, String userName, String password) throws SQLException {
    dataSource = new BasicDataSource();
    dataSource.setDriverClassName(driverName);
    dataSource.setUsername(userName);
    dataSource.setPassword(password);
    dataSource.setUrl(driverUrl);

    dataSource.setDefaultReadOnly(false);
    dataSource.setDefaultAutoCommit(false);

    // enable detection and logging of connection leaks
    dataSource.setRemoveAbandonedOnBorrow(true);
    dataSource.setRemoveAbandonedOnMaintenance(true);
    dataSource.setRemoveAbandonedTimeout(3600); // 1 hour
    dataSource.setLogAbandoned(true);
    dataSource.setMaxWaitMillis(60000);
    dataSource.setMaxTotal(20);

    INITDATE = new Date();
}
 
开发者ID:statsbiblioteket,项目名称:licensemodule,代码行数:21,代码来源:LicenseModuleStorage.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: getPooledDataSource

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
public static BasicDataSource getPooledDataSource(String connectUrl,
                                             int maxTotal,
                                             int maxWaitTimeMillis) {
  BasicDataSource bds = new BasicDataSource();
  bds.setUrl(connectUrl);
  bds.setMaxTotal(maxTotal);
  bds.setMaxWaitMillis(maxWaitTimeMillis);
  return bds;
}
 
开发者ID:aol,项目名称:chronos,代码行数:10,代码来源:Utils.java

示例11: 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

示例12: sqlSessionFactory

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
public SqlSessionFactory sqlSessionFactory(String configXml) {
    GlobalConfiguration global = this.globalConfiguration();
    BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName("com.mysql.jdbc.Driver");
    dataSource.setUrl("jdbc:mysql://127.0.0.1:3306/mybatis-plus?characterEncoding=UTF-8");
    dataSource.setUsername("root");
    dataSource.setPassword("521");
    dataSource.setMaxTotal(1000);
    GlobalConfigUtils.setMetaData(dataSource, global);
    // 加载配置文件
    InputStream inputStream = CrudTest.class.getClassLoader().getResourceAsStream(configXml);
    MybatisSessionFactoryBuilder factoryBuilder = new MybatisSessionFactoryBuilder();
    factoryBuilder.setGlobalConfig(global);
    return factoryBuilder.build(inputStream);
}
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:16,代码来源:CrudTest.java

示例13: createDataSourceMetadata

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
private CommonsDbcp2DataSourcePoolMetadata createDataSourceMetadata(int minSize,
		int maxSize) {
	BasicDataSource dataSource = createDataSource();
	dataSource.setMinIdle(minSize);
	dataSource.setMaxTotal(maxSize);
	return new CommonsDbcp2DataSourcePoolMetadata(dataSource);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:CommonsDbcp2DataSourcePoolMetadataTests.java

示例14: TestDataSource

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
public TestDataSource(String connUrl, String user, String password) {
    dataSource = new BasicDataSource();
    dataSource.setUrl(connUrl);
    dataSource.setUsername(user);
    dataSource.setPassword(password);
    dataSource.setMaxTotal(20);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:8,代码来源:TestDataSource.java

示例15: setupDataSourcePool

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
@Override
protected BasicDataSource setupDataSourcePool( DataSourceConfiguration 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.setMaxTotal( 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;
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:34,代码来源:DBCPDataSourceServiceImporter.java


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