當前位置: 首頁>>代碼示例>>Java>>正文


Java BasicDataSource.setMinEvictableIdleTimeMillis方法代碼示例

本文整理匯總了Java中org.apache.commons.dbcp2.BasicDataSource.setMinEvictableIdleTimeMillis方法的典型用法代碼示例。如果您正苦於以下問題:Java BasicDataSource.setMinEvictableIdleTimeMillis方法的具體用法?Java BasicDataSource.setMinEvictableIdleTimeMillis怎麽用?Java BasicDataSource.setMinEvictableIdleTimeMillis使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.dbcp2.BasicDataSource的用法示例。


在下文中一共展示了BasicDataSource.setMinEvictableIdleTimeMillis方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

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

示例2: chatDataSource

import org.apache.commons.dbcp2.BasicDataSource; //導入方法依賴的package包/類
@Bean
public DataSource chatDataSource() throws ConfigurationException, IOException {
	BasicDataSource datasource = new BasicDataSource();
	String path = this.configuration().getString(GlobalConfig.DB_PATH);
	if (path == null) {
		path = GlobalConfig.DB_PATH_DEFAULT;
	}
	datasource.setUsername(this.configuration().getString(GlobalConfig.DB_USERNAME));
	datasource.setPassword(this.configuration().getString(GlobalConfig.DB_PASSWORD));
	datasource.setDriverClassName("org.h2.Driver");
	datasource.setUrl("jdbc:h2:" + path);
	datasource.setMaxIdle(3);
	datasource.setMaxWaitMillis(5000);
	datasource.setRemoveAbandonedOnBorrow(true);
	datasource.setRemoveAbandonedOnBorrow(true);
	datasource.setRemoveAbandonedTimeout(20);
	datasource.setLogAbandoned(true);
	datasource.setValidationQuery("select 1");
	datasource.setMinEvictableIdleTimeMillis(3600000);
	datasource.setTimeBetweenEvictionRunsMillis(1800000);
	datasource.setNumTestsPerEvictionRun(10);
	datasource.setTestOnBorrow(true);
	datasource.setTestOnReturn(false);
	datasource.addConnectionProperty("useUnicode", "yes");
	datasource.addConnectionProperty("characterEncoding", "utf8");
	return datasource;
}
 
開發者ID:shilongdai,項目名稱:LSChatServer,代碼行數:28,代碼來源:ApplicationRootContext.java

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

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


注:本文中的org.apache.commons.dbcp2.BasicDataSource.setMinEvictableIdleTimeMillis方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。