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


Java PoolProperties.setMaxIdle方法代碼示例

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


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

示例1: TomcatSchema

import org.apache.tomcat.jdbc.pool.PoolProperties; //導入方法依賴的package包/類
public TomcatSchema(@Nonnull Config config) {
	checkNotNull(config);

	log.debug("{} sql.url: {}", config.getName(), config.getString("sql.url"));

	PoolProperties poolProps = new PoolProperties();
	poolProps.setUrl(config.getString("sql.url"));
	poolProps.setUsername(config.getString("sql.login"));
	poolProps.setPassword(config.getString("sql.password"));
	poolProps.setDriverClassName(config.getString("sql.driver"));
	poolProps.setMinIdle(config.getInt("sql.pool.minIdle", 1));
	poolProps.setMaxIdle(config.getInt("sql.pool.maxIdle", 3));
	poolProps.setMaxActive(config.getInt("sql.pool.maxActive", 5));
	poolProps.setInitialSize(poolProps.getMinIdle());
	poolProps.setValidationQuery("SELECT 1");
	poolProps.setValidationQueryTimeout((int) config.getTime("sql.pool.validationQueryTimeout", "5s"));
	poolProps.setTestOnBorrow(config.getBoolean("sql.pool.testOnBorrow", true));
	poolProps.setDefaultReadOnly(config.getBoolean("sql.pool.defaultReadOnly", true));
	dataSource = new DataSource(poolProps);
	streaming = config.getBoolean("sql.streaming", false);
}
 
開發者ID:lithiumtech,項目名稱:flow,代碼行數:22,代碼來源:TomcatSchema.java

示例2: initDataSource

import org.apache.tomcat.jdbc.pool.PoolProperties; //導入方法依賴的package包/類
private void initDataSource(String dataSourceFile) {
    Properties dataSourceProps = getPropertiesFromClasspath(dataSourceFile);
    PoolProperties p = new PoolProperties();
    p.setUrl(dataSourceProps.getProperty("url"));
    p.setDriverClassName(dataSourceProps.getProperty("driverClassName"));
    p.setUsername(dataSourceProps.getProperty("username"));
    p.setPassword(dataSourceProps.getProperty("password"));
    p.setMaxIdle(Integer.valueOf(dataSourceProps.getProperty("maxIdle")));
    p.setMinIdle(Integer.valueOf(dataSourceProps.getProperty("minIdle")));
    p.setInitialSize(Integer.valueOf(dataSourceProps.getProperty("initialSize")));
    p.setMaxWait(Integer.valueOf(dataSourceProps.getProperty("maxWait")));
    p.setMaxActive(Integer.valueOf(dataSourceProps.getProperty("maxActive")));
    p.setTestOnBorrow(Boolean.valueOf(dataSourceProps.getProperty("testOnBorrow")));
    p.setTestOnReturn(Boolean.valueOf(dataSourceProps.getProperty("testOnReturn")));
    p.setTestWhileIdle(Boolean.valueOf(dataSourceProps.getProperty("testWhileIdle")));
    p.setValidationQuery(dataSourceProps.getProperty("validationQuery"));
    p.setValidationQueryTimeout(Integer.valueOf(dataSourceProps.getProperty("validationQueryTimeout")));
    p.setTimeBetweenEvictionRunsMillis(Integer.valueOf(dataSourceProps.getProperty("timeBetweenEvictionRunsMillis")));
    p.setMinEvictableIdleTimeMillis(Integer.valueOf(dataSourceProps.getProperty("minEvictableIdleTimeMillis")));
    p.setRemoveAbandoned(Boolean.valueOf(dataSourceProps.getProperty("removeAbandoned")));
    p.setRemoveAbandonedTimeout(Integer.valueOf(dataSourceProps.getProperty("removeAbandonedTimeout")));
    p.setValidationInterval(Integer.valueOf(dataSourceProps.getProperty("validationInterval")));
    p.setLogAbandoned(Boolean.valueOf(dataSourceProps.getProperty("logAbandoned")));
    p.setFairQueue(Boolean.valueOf(dataSourceProps.getProperty("fairQueue")));
    dataSource.setPoolProperties(p);
}
 
開發者ID:edgar615,項目名稱:javase-study,代碼行數:27,代碼來源:DaoManager.java

示例3: dataSource

import org.apache.tomcat.jdbc.pool.PoolProperties; //導入方法依賴的package包/類
@Primary
@Bean
public DataSource dataSource() {
    DbConfiguration dbConfiguration = configurationService.getDbConfiguration();

    PoolProperties poolProperties = new PoolProperties();
    poolProperties.setDriverClassName(dbConfiguration.getDriverClassName());
    poolProperties.setUrl(dbConfiguration.getUrl());
    poolProperties.setUsername(dbConfiguration.getUser());
    poolProperties.setPassword(dbConfiguration.getPassword());
    poolProperties.setMaxActive(dbConfiguration.getMaxActive());
    poolProperties.setMaxIdle(dbConfiguration.getMaxIdle());
    poolProperties.setMinIdle(dbConfiguration.getMinIdle());
    poolProperties.setMaxWait(dbConfiguration.getMaxWait());
    poolProperties.setValidationQuery(dbConfiguration.getValidationQuery());
    poolProperties.setTestOnBorrow(dbConfiguration.getTestOnBorrow());
    poolProperties.setTestWhileIdle(dbConfiguration.getTestWhileIdle());

    return new org.apache.tomcat.jdbc.pool.DataSource(poolProperties);

}
 
開發者ID:mcgray,項目名稱:Medium-test-poc,代碼行數:22,代碼來源:DataSourceConfiguration.java

示例4: dataSource

import org.apache.tomcat.jdbc.pool.PoolProperties; //導入方法依賴的package包/類
@Bean
public DataSource dataSource() {
    logger.info("Create DataSource bean. JDBC URL " + env.getProperty("database.url") + ", for username: " + env.getProperty("database.user"));
    try {
        PoolProperties poolProperties = new PoolProperties();
        poolProperties.setUsername(env.getProperty("database.user"));
        poolProperties.setPassword(env.getProperty("database.password"));
        poolProperties.setUrl(env.getProperty("database.url"));
        poolProperties.setDriverClassName("com.mysql.jdbc.Driver");
        poolProperties.setMaxActive(50);
        poolProperties.setMaxIdle(50);
        poolProperties.setInitialSize(1);

        return new DataSource(poolProperties);
    } catch (Exception ex) {
        logger.error(ex.getMessage(), ex);
        throw new RuntimeException(ex);
    }
}
 
開發者ID:shivam091,項目名稱:Spring-Security-Thymeleaf-Integration,代碼行數:20,代碼來源:AppConfig.java

示例5: createPool

import org.apache.tomcat.jdbc.pool.PoolProperties; //導入方法依賴的package包/類
public static void createPool() throws Exception {
// Modify this code in order to extract a Connection from your
// connection pooling system:

// Driver parameters to use:
String driverClassName = "org.postgresql.Driver";
String url = "jdbc:postgresql://localhost:5432/kawansoft_example";
String username = "user1";
String password = "password1";

// Creating the DataSource bean and populating the values:
// Mandatory values to set
PoolProperties p = new PoolProperties();
p.setDriverClassName(driverClassName);
p.setUrl(url);
p.setUsername(username);
p.setPassword(password);

// Other possible values to set
p.setTestOnBorrow(true);
p.setValidationQuery("SELECT 1");
p.setTestOnReturn(false);
p.setValidationInterval(30000);
p.setTimeBetweenEvictionRunsMillis(30000);
p.setMaxActive(2);
p.setInitialSize(2);
p.setMaxWait(10000);
p.setRemoveAbandonedTimeout(60);
p.setMinEvictableIdleTimeMillis(30000);
p.setMinIdle(2);
p.setMaxIdle(2);
p.setLogAbandoned(true);
p.setRemoveAbandoned(true);
p.setJdbcInterceptors("ConnectionState;StatementFinalizer");

dataSource = new DataSource();
dataSource.setPoolProperties(p);

   }
 
開發者ID:kawansoft,項目名稱:aceql-http,代碼行數:40,代碼來源:TestTomcatJdbcPoolBehavior.java

示例6: start

import org.apache.tomcat.jdbc.pool.PoolProperties; //導入方法依賴的package包/類
@Override
public void start() {
	PoolProperties p = new PoolProperties();
	p.setUrl(this.conURL);
	p.setDriverClassName(this.driverName);
	p.setUsername(this.username);
	p.setPassword(this.password);
	p.setJmxEnabled(false);
	if (this.testSql != null && this.testSql.trim().length() > 0) {
		p.setValidationQuery(this.testSql);
		p.setTestWhileIdle(true);
		p.setTimeBetweenEvictionRunsMillis(15 * 1000);
		boolean tbf = AppProperties.getAsBoolean(
				"TomcatJdbcPool_TestOnBorrow", false);
		p.setTestOnBorrow(tbf);// 獲取之前是否校驗
		p.setTestOnReturn(false);
		p.setValidationInterval(30000);
	}
	p.setMaxActive(this.max);
	p.setMaxIdle(this.max);
	p.setInitialSize(this.min);
	p.setMinIdle(min);
	int maxwaitfornoconn = AppProperties.getAsInt("TomcatJdbcPool_MaxWait",
			30 * 1000);
	p.setMaxWait(maxwaitfornoconn);
	boolean removeAbandonedFlag = AppProperties.getAsBoolean(
			"TomcatJdbcPool_RemoveAbandoned", false);
	if (removeAbandonedFlag) {
		p.setLogAbandoned(true);
		p.setRemoveAbandoned(true);
		p.setRemoveAbandonedTimeout(AppProperties.getAsInt(
				"TomcatJdbcPool_RemoveAbandonedTimeout", 60));
	}
	// p.setMinEvictableIdleTimeMillis(30000);
	p.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;"
			+ "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer");
	datasource = new DataSource();
	datasource.setPoolProperties(p);
	try {
		datasource.createPool();
	} catch (SQLException e) {
		datasource.close();
		throw new AppRuntimeException("start tomcat pool err", e);
	}
}
 
開發者ID:jbeetle,項目名稱:BJAF3.x,代碼行數:46,代碼來源:TomcatJdbcPool.java

示例7: setAllPoolProperties

import org.apache.tomcat.jdbc.pool.PoolProperties; //導入方法依賴的package包/類
public void setAllPoolProperties() throws Exception {
	poolProperties = new PoolProperties();

	//todo: probably more ifs to provide more information of which wasn't defined.
	if (url == null || driverClassName == null || userName == null || password == null) {
		throw new Exception("A mandatory item wasn't defined correctly");
	} else {
		//Mandatory items.
		poolProperties.setUrl(url);
		poolProperties.setDriverClassName(driverClassName);
		poolProperties.setUsername(userName);
		poolProperties.setPassword(password);

		//Not Mandatory Items.
		if (abandonWhenPercentageFull != null)
			poolProperties.setAbandonWhenPercentageFull(abandonWhenPercentageFull);
		if (accessToUnderlyingConnectionAllowed != null)
			poolProperties.setAccessToUnderlyingConnectionAllowed(accessToUnderlyingConnectionAllowed);
		if (alternateUsernameAllowed != null) poolProperties.setAlternateUsernameAllowed(alternateUsernameAllowed);
		if (commitOnReturn != null) poolProperties.setCommitOnReturn(commitOnReturn);
		if (connectionProperties != null) poolProperties.setConnectionProperties(connectionProperties);
		if (dataSource != null) poolProperties.setDataSource(dataSource); //todo: probably a problem.
		if (dataSourceJNDI != null) poolProperties.setDataSourceJNDI(dataSourceJNDI);
		if (dbProperties != null) poolProperties.setDbProperties(dbProperties);
		if (defaultAutoCommit != null) poolProperties.setDefaultAutoCommit(defaultAutoCommit);
		if (defaultCatalog != null) poolProperties.setDefaultCatalog(defaultCatalog);
		if (defaultReadOnly != null) poolProperties.setDefaultReadOnly(defaultReadOnly);
		if (defaultTranslationIsolation != null)
			poolProperties.setDefaultTransactionIsolation(defaultTranslationIsolation);
		if (fairQueue != null) poolProperties.setFairQueue(fairQueue);
		if (ignoreExceptionOnPreLoad != null) poolProperties.setIgnoreExceptionOnPreLoad(ignoreExceptionOnPreLoad);
		if (initialSize != null) poolProperties.setInitialSize(initialSize);
		if (initSQL != null) poolProperties.setInitSQL(initSQL);
		if (jdbcInterceptors != null) poolProperties.setJdbcInterceptors(jdbcInterceptors);
		if (jmxEnabled != null) poolProperties.setJmxEnabled(jmxEnabled);
		if (logAbandoned != null) poolProperties.setLogAbandoned(logAbandoned);
		if (logValidationErrors != null) poolProperties.setLogValidationErrors(logValidationErrors);
		if (maxActive != null) poolProperties.setMaxActive(maxActive);
		if (maxAge != null) poolProperties.setMaxAge(maxAge);
		if (maxIdle != null) poolProperties.setMaxIdle(maxIdle);
		if (maxWait != null) poolProperties.setMaxWait(maxWait);
		if (minEvictableIdleTimeMillis != null)
			poolProperties.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
		if (minIdle != null) poolProperties.setMinIdle(minIdle);
		if (name != null) poolProperties.setName(name);
		if (numTestsPerEvictionRun != null) poolProperties.setNumTestsPerEvictionRun(numTestsPerEvictionRun);
		if (propagateInterruptState != null) poolProperties.setPropagateInterruptState(propagateInterruptState);
		if (removeAbandoned != null) poolProperties.setRemoveAbandoned(removeAbandoned);
		if (removeAbandonedTimeout != null) poolProperties.setRemoveAbandonedTimeout(removeAbandonedTimeout);
		if (rollbackOnReturn != null) poolProperties.setRollbackOnReturn(rollbackOnReturn);
		if (suspectTimeout != null) poolProperties.setSuspectTimeout(suspectTimeout);
		if (testOnBorrow != null) poolProperties.setTestOnBorrow(testOnBorrow);
		if (testOnConnect != null) poolProperties.setTestOnConnect(testOnConnect);
		if (testOnReturn != null) poolProperties.setTestOnReturn(testOnReturn);
		if (testWhileIdle != null) poolProperties.setTestWhileIdle(testWhileIdle);
		if (timeBetweenEvictionsRunMillis != null)
			poolProperties.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionsRunMillis);
		if (useDisposableConnectionFacade != null)
			poolProperties.setUseDisposableConnectionFacade(useDisposableConnectionFacade);
		if (useEquals != null) poolProperties.setUseEquals(useEquals);
		if (useLock != null) poolProperties.setUseLock(useLock);
		if (validationInterval != null) poolProperties.setValidationInterval(validationInterval);
		if (validationQuery != null) poolProperties.setValidationQuery(validationQuery);
		if (validationQueryTimeout != null) poolProperties.setValidationQueryTimeout(validationQueryTimeout);
		if (validator != null) poolProperties.setValidator(validator);
		if (validatorClassName != null) poolProperties.setValidatorClassName(validatorClassName);

		//Set the DataSource Provider's Properties.
		dataSourceProvider = new DataSource();
		dataSourceProvider.setPoolProperties(poolProperties);
	}
}
 
開發者ID:Bonsanto,項目名稱:db-component,代碼行數:73,代碼來源:DBConnection.java

示例8: ArtifactoryTomcatDataSource

import org.apache.tomcat.jdbc.pool.PoolProperties; //導入方法依賴的package包/類
public ArtifactoryTomcatDataSource(StorageProperties s) {
    // see org.apache.tomcat.jdbc.pool.DataSourceFactory.parsePoolProperties()
    PoolProperties p = new PoolProperties();
    p.setUrl(s.getConnectionUrl());
    p.setDriverClassName(s.getDriverClass());
    p.setUsername(s.getUsername());
    p.setPassword(s.getPassword());

    p.setDefaultAutoCommit(false);
    p.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);

    p.setInitialSize(s.getIntProperty("initialSize", 1));
    p.setMaxAge(s.getIntProperty("maxAge", 0));
    p.setMaxActive(s.getMaxActiveConnections());
    p.setMaxWait(s.getIntProperty("maxWait", (int) TimeUnit.SECONDS.toMillis(120)));
    p.setMaxIdle(s.getMaxIdleConnections());
    p.setMinIdle(s.getIntProperty("minIdle", 1));
    p.setMinEvictableIdleTimeMillis(
            s.getIntProperty("minEvictableIdleTimeMillis", 300000));
    p.setTimeBetweenEvictionRunsMillis(
            s.getIntProperty("timeBetweenEvictionRunsMillis", 30000));
    p.setInitSQL(s.getProperty("initSQL", null));

    // validation query for all kind of tests (connect, borrow etc.)
    p.setValidationQuery(s.getProperty("validationQuery", getDefaultValidationQuery(s)));
    p.setValidationQueryTimeout(s.getIntProperty("validationQueryTimeout", 30));
    p.setValidationInterval(s.getLongProperty("validationInterval", 30000));
    p.setTestOnBorrow(s.getBooleanProperty("testOnBorrow", true));
    p.setTestWhileIdle(s.getBooleanProperty("testWhileIdle", false));
    p.setTestOnReturn(s.getBooleanProperty("testOnReturn", false));
    p.setTestOnConnect(s.getBooleanProperty("testOnConnect", false));

    p.setRemoveAbandoned(s.getBooleanProperty("removeAbandoned", false));
    p.setRemoveAbandonedTimeout(s.getIntProperty("removeAbandonedTimeout", 600));
    p.setSuspectTimeout(s.getIntProperty("suspectTimeout", 600));
    p.setLogAbandoned(s.getBooleanProperty("logAbandoned", false));
    p.setLogValidationErrors(s.getBooleanProperty("logValidationErrors", false));

    p.setJmxEnabled(s.getBooleanProperty("jmxEnabled", true));

    // only applicable if auto commit is false. has high performance penalty and only protects bugs in the code
    p.setRollbackOnReturn(s.getBooleanProperty("rollbackOnReturn", false));
    p.setCommitOnReturn(s.getBooleanProperty("commitOnReturn", false));

    p.setIgnoreExceptionOnPreLoad(s.getBooleanProperty("ignoreExceptionOnPreLoad", false));

    //p.setJdbcInterceptors(s.getProperty("jdbcInterceptors", "ConnectionState;StatementFinalizer"));
    p.setJdbcInterceptors(s.getProperty("jdbcInterceptors", null));

    p.setDefaultCatalog(s.getProperty("defaultCatalog", null));

    setPoolProperties(p);
}
 
開發者ID:alancnet,項目名稱:artifactory,代碼行數:54,代碼來源:ArtifactoryTomcatDataSource.java

示例9: createUniqueIdDataSource

import org.apache.tomcat.jdbc.pool.PoolProperties; //導入方法依賴的package包/類
public static DataSource createUniqueIdDataSource(StorageProperties s) {
    // see org.apache.tomcat.jdbc.pool.DataSourceFactory.parsePoolProperties()
    PoolProperties p = new PoolProperties();
    p.setUrl(s.getConnectionUrl());
    p.setDriverClassName(s.getDriverClass());
    p.setUsername(s.getUsername());
    p.setPassword(s.getPassword());

    // auto commit is true for the unique id generator
    p.setDefaultAutoCommit(true);
    p.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);

    // only one connection is required for the id generator
    p.setInitialSize(1);
    p.setMinIdle(1);
    p.setMaxIdle(1);
    p.setMaxActive(1);
    p.setMaxAge(s.getIntProperty("maxAge", 0));
    p.setMaxWait(s.getIntProperty("maxWait", (int) TimeUnit.SECONDS.toMillis(120)));
    p.setMinEvictableIdleTimeMillis(
            s.getIntProperty("minEvictableIdleTimeMillis", 300000));
    p.setTimeBetweenEvictionRunsMillis(
            s.getIntProperty("timeBetweenEvictionRunsMillis", 30000));
    p.setInitSQL(s.getProperty("initSQL", null));

    // validation query for all kind of tests (connect, borrow etc.)
    p.setValidationQuery(s.getProperty("validationQuery", getDefaultValidationQuery(s)));
    p.setValidationQueryTimeout(s.getIntProperty("validationQueryTimeout", 30));
    p.setValidationInterval(s.getLongProperty("validationInterval", 30000));
    p.setTestOnBorrow(s.getBooleanProperty("testOnBorrow", true));
    p.setTestWhileIdle(s.getBooleanProperty("testWhileIdle", false));
    p.setTestOnReturn(s.getBooleanProperty("testOnReturn", false));
    p.setTestOnConnect(s.getBooleanProperty("testOnConnect", false));

    p.setRemoveAbandoned(s.getBooleanProperty("removeAbandoned", false));
    p.setRemoveAbandonedTimeout(s.getIntProperty("removeAbandonedTimeout", 600));
    p.setSuspectTimeout(s.getIntProperty("suspectTimeout", 600));
    p.setLogAbandoned(s.getBooleanProperty("logAbandoned", false));
    p.setLogValidationErrors(s.getBooleanProperty("logValidationErrors", false));

    p.setJmxEnabled(false);

    p.setIgnoreExceptionOnPreLoad(s.getBooleanProperty("ignoreExceptionOnPreLoad", false));

    //p.setJdbcInterceptors(s.getProperty("jdbcInterceptors", "ConnectionState;StatementFinalizer"));
    p.setJdbcInterceptors(s.getProperty("jdbcInterceptors", null));

    p.setDefaultCatalog(s.getProperty("defaultCatalog", null));

    return new DataSource(p);
}
 
開發者ID:alancnet,項目名稱:artifactory,代碼行數:52,代碼來源:ArtifactoryTomcatDataSource.java


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