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


Java BasicDataSource.setTestWhileIdle方法代码示例

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


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

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

示例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/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

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

示例4: retrySetup

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
private void retrySetup(BasicDataSource ds) {
	if (!"org.hibernate.dialect.HSQLDialect".equals(mainEnv.getDialect())) {
		ds.setTestOnBorrow(dbcpEnv.isTestOnBorrow());
		ds.setValidationQuery(dbcpEnv.getValidationQuery());
		ds.setMaxTotal(dbcpEnv.getMaxTotal());
		ds.setMinEvictableIdleTimeMillis(dbcpEnv.getMinEvictableIdleTime());
		ds.setTimeBetweenEvictionRunsMillis(dbcpEnv.getTimeBetweenEvictionRuns());
		ds.setNumTestsPerEvictionRun(dbcpEnv.getNumTestsPerEvictionRun());
		ds.setTestWhileIdle(dbcpEnv.isTestWhileIdle());
		ds.setTestOnReturn(dbcpEnv.isTestOnReturn());
	}
}
 
开发者ID:aol,项目名称:micro-server,代码行数:13,代码来源:DBCPDataSourceBuilder.java

示例5: setupDataSource

import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
private static BasicDataSource setupDataSource(String server, int port, String dbName,
                                               String username,
                                               String password, int maxActive, int maxIdle) {
    Preconditions.checkNotNull(server);
    Preconditions.checkNotNull(dbName);
    Preconditions.checkNotNull(username);

    BasicDataSource ds = new BasicDataSource();
    ds.setDriverClassName("com.mysql.jdbc.Driver");
    ds.setUsername(username);

    if (password.length() > 0) {
        ds.setPassword(password);
    }

    String
            url =
            String.format("jdbc:mysql://%s:%d/%s?useConfigs=maxPerformance&useCompression=true",
                          server, port, dbName);
    ds.setUrl(url);
    ds.setValidationQuery("SELECT 1;");
    ds.setTestWhileIdle(true);
    ds.setTestOnReturn(true);
    ds.setMaxTotal(maxActive);
    ds.setMaxIdle(maxIdle);
    ds.setRemoveAbandonedOnBorrow(true);
    ds.setRemoveAbandonedTimeout(60);

    if (Configuration.getInstance().isDeveloperMode()) {
        ds.setLogAbandoned(true);
    }

    sLogger.info("created new Connectionpool");
    return ds;
}
 
开发者ID:anycook,项目名称:anycook-api,代码行数:36,代码来源:DBHandler.java


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