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


Java ComboPooledDataSource.getMaxPoolSize方法代码示例

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


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

示例1: getMaxConnectionsNumber

import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
@Override
public int getMaxConnectionsNumber(DataSource dataSource) {
	try {
		ComboPooledDataSource ds = (ComboPooledDataSource)dataSource;
		return ds.getMaxPoolSize();
	} catch (Exception e) {
		if(logger.isDebugEnabled()){
			logger.debug(" query C3P0 datasource="+dataSource+" max connections number fail");
		}
		return IllegalNumber;
	}
}
 
开发者ID:sogou-biztech,项目名称:compass,代码行数:13,代码来源:C3P0DatabasePropertiesReteriver.java

示例2: initDataSource

import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
/**
 * Initializes the connection pool.
 * @param dbSpec the object representing the chosen DB target system.
 * @param jdbcUrl the JDBC URL to connect to.
 * @throws SQLException 
 */
private static void initDataSource(DBSpecifics dbSpec, String jdbcUrl)
throws SQLException {

    dataSource = new ComboPooledDataSource();
    String username = Settings.get(ArchiveSettings.DB_USERNAME);
    if (!username.isEmpty()) {
        dataSource.setUser(username);
    }
    String password = Settings.get(ArchiveSettings.DB_PASSWORD);
    if (!password.isEmpty()) {
        dataSource.setPassword(password);
    }
    try {
        dataSource.setDriverClass(dbSpec.getDriverClassName());
    } catch (PropertyVetoException e) {
        final String message =
            "Failed to set datasource JDBC driver class '"
            + dbSpec.getDriverClassName() + "'" + "\n";
        throw new IOFailure(message, e);
    }
    dataSource.setJdbcUrl(jdbcUrl);

    // Configure pool size
    dataSource.setMinPoolSize(
            Settings.getInt(ArchiveSettings.DB_POOL_MIN_SIZE));
    dataSource.setMaxPoolSize(
            Settings.getInt(ArchiveSettings.DB_POOL_MAX_SIZE));
    dataSource.setAcquireIncrement(
            Settings.getInt(ArchiveSettings.DB_POOL_ACQ_INC));

    // Configure idle connection testing
    int testPeriod =
        Settings.getInt(ArchiveSettings.DB_POOL_IDLE_CONN_TEST_PERIOD);
    if (testPeriod > 0) {
        dataSource.setIdleConnectionTestPeriod(testPeriod);
        dataSource.setTestConnectionOnCheckin(
                Settings.getBoolean(
                        ArchiveSettings.DB_POOL_IDLE_CONN_TEST_ON_CHECKIN));
        String testQuery =
            Settings.get(ArchiveSettings.DB_POOL_IDLE_CONN_TEST_QUERY);
        if (!testQuery.isEmpty()) {
            dataSource.setPreferredTestQuery(testQuery);
        }
    }

    // Configure statement pooling
    dataSource.setMaxStatements(
            Settings.getInt(ArchiveSettings.DB_POOL_MAX_STM));
    dataSource.setMaxStatementsPerConnection(
            Settings.getInt(ArchiveSettings.DB_POOL_MAX_STM_PER_CONN));

    if (log.isInfoEnabled()) {
        String msg = 
                "Connection pool initialized with the following values:";
        msg += "\n- minPoolSize=" + dataSource.getMinPoolSize();
        msg += "\n- maxPoolSize=" + dataSource.getMaxPoolSize();
        msg += "\n- acquireIncrement=" + dataSource.getAcquireIncrement();
        msg += "\n- maxStatements=" + dataSource.getMaxStatements();
        msg += "\n- maxStatementsPerConnection="
            + dataSource.getMaxStatementsPerConnection();
        msg += "\n- idleConnTestPeriod="
            + dataSource.getIdleConnectionTestPeriod();
        msg += "\n- idleConnTestQuery='"
            + dataSource.getPreferredTestQuery() + "'";
        msg += "\n- idleConnTestOnCheckin="
            + dataSource.isTestConnectionOnCheckin();
        log.info(msg.toString());
    }
}
 
开发者ID:netarchivesuite,项目名称:netarchivesuite-svngit-migration,代码行数:76,代码来源:ArchiveDBConnection.java

示例3: initDataSource

import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
/**
 * Initializes the connection pool.
 * @param dbSpec the object representing the chosen DB target system.
 * @param jdbcUrl the JDBC URL to connect to.
 * @throws SQLException 
 */
private static void initDataSource(DBSpecifics dbSpec, String jdbcUrl)
throws SQLException {

    dataSource = new ComboPooledDataSource();
    try {
        dataSource.setDriverClass(dbSpec.getDriverClassName());
    } catch (PropertyVetoException e) {
        final String message =
            "Failed to set datasource JDBC driver class '"
            + dbSpec.getDriverClassName() + "'" + "\n";
        throw new IOFailure(message, e);
    }
    dataSource.setJdbcUrl(jdbcUrl);
    String username = Settings.get(CommonSettings.DB_USERNAME);
    if (!username.isEmpty()) {
        dataSource.setUser(username);
    }
    String password = Settings.get(CommonSettings.DB_PASSWORD);
    if (!password.isEmpty()) {
        dataSource.setPassword(password);
    }
    // Configure pool size
    dataSource.setMinPoolSize(
            Settings.getInt(CommonSettings.DB_POOL_MIN_SIZE));
    dataSource.setMaxPoolSize(
            Settings.getInt(CommonSettings.DB_POOL_MAX_SIZE));
    dataSource.setAcquireIncrement(
            Settings.getInt(CommonSettings.DB_POOL_ACQ_INC));

    // Configure idle connection testing
    int testPeriod =
        Settings.getInt(CommonSettings.DB_POOL_IDLE_CONN_TEST_PERIOD);
    //TODO This looks odd. Why is checkin-testing inside this if statement?
    if (testPeriod > 0) {
        dataSource.setIdleConnectionTestPeriod(testPeriod);
        dataSource.setTestConnectionOnCheckin(
                Settings.getBoolean(
                        CommonSettings.DB_POOL_IDLE_CONN_TEST_ON_CHECKIN));
        String testQuery =
            Settings.get(CommonSettings.DB_POOL_IDLE_CONN_TEST_QUERY);
        if (!testQuery.isEmpty()) {
            dataSource.setPreferredTestQuery(testQuery);
        }
    }

    // Configure statement pooling
    dataSource.setMaxStatements(
            Settings.getInt(CommonSettings.DB_POOL_MAX_STM));
    dataSource.setMaxStatementsPerConnection(
            Settings.getInt(CommonSettings.DB_POOL_MAX_STM_PER_CONN));

    //dataSource.setTestConnectionOnCheckout(true);
    //dataSource.setBreakAfterAcquireFailure(false);
    //dataSource.setAcquireRetryAttempts(10000);
    //dataSource.setAcquireRetryDelay(10);

    if (log.isInfoEnabled()) {
        String msg = 
                "Connection pool initialized with the following values:";
        msg += "\n- minPoolSize=" + dataSource.getMinPoolSize();
        msg += "\n- maxPoolSize=" + dataSource.getMaxPoolSize();
        msg += "\n- acquireIncrement=" + dataSource.getAcquireIncrement();
        msg += "\n- maxStatements=" + dataSource.getMaxStatements();
        msg += "\n- maxStatementsPerConnection="
            + dataSource.getMaxStatementsPerConnection();
        msg += "\n- idleConnTestPeriod="
            + dataSource.getIdleConnectionTestPeriod();
        msg += "\n- idleConnTestQuery='"
            + dataSource.getPreferredTestQuery() + "'";
        msg += "\n- idleConnTestOnCheckin="
            + dataSource.isTestConnectionOnCheckin();
        log.info(msg.toString());
    }
}
 
开发者ID:netarchivesuite,项目名称:netarchivesuite-svngit-migration,代码行数:81,代码来源:HarvestDBConnection.java


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