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


Java ComboPooledDataSource.setMaxIdleTime方法代码示例

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


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

示例1: start

import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
public boolean start() {
    if (isStarted)
        return true;

    dataSource = new ComboPooledDataSource();
    dataSource.setJdbcUrl(jdbcUrl);
    dataSource.setUser(user);
    dataSource.setPassword(password);
    try {
        dataSource.setDriverClass(driverClass);
    } catch (PropertyVetoException e) {
        dataSource = null;
        logger.error("C3p0Plugin start error");
        throw new RuntimeException(e);
    }
    dataSource.setMaxPoolSize(maxPoolSize);
    dataSource.setMinPoolSize(minPoolSize);
    dataSource.setInitialPoolSize(initialPoolSize);
    dataSource.setMaxIdleTime(maxIdleTime);
    dataSource.setAcquireIncrement(acquireIncrement);

    isStarted = true;
    return true;
}
 
开发者ID:T-baby,项目名称:ICERest-plugin,代码行数:25,代码来源:C3p0Plugin.java

示例2: createNewDataSource

import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
private ComboPooledDataSource createNewDataSource() throws Exception {
    ComboPooledDataSource c3p0DataSource = new ComboPooledDataSource();

    c3p0DataSource.setDriverClass(config.getDriverClassName()); //loads the jdbc driver
    c3p0DataSource.setJdbcUrl(config.getJdbcUrl());
    c3p0DataSource.setUser(config.getUserName());
    c3p0DataSource.setPassword(config.getPassword());

    // the settings below are optional -- c3p0 can work with defaults
    c3p0DataSource.setMinPoolSize(config.getMinPoolSize());
    c3p0DataSource.setMaxPoolSize(config.getMaxPoolSize());
    c3p0DataSource.setAcquireIncrement(config.getAcquireIncrement());
    c3p0DataSource.setMaxStatements(config.getMaxStatements());
    c3p0DataSource.setIdleConnectionTestPeriod(config.getIdleTestPeriod());
    c3p0DataSource.setMaxIdleTime(config.getMaxIdleTime());

    return c3p0DataSource;
}
 
开发者ID:hekailiang,项目名称:cloud-config,代码行数:19,代码来源:C3P0DataSourceFactoryBean.java

示例3: datasource

import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
@Bean(name = "NextRTCDataSource", destroyMethod = "close")
public ComboPooledDataSource datasource() throws PropertyVetoException {
    ComboPooledDataSource ds = new ComboPooledDataSource();
    ds.setMinPoolSize(1);
    ds.setMaxPoolSize(10);
    ds.setCheckoutTimeout(30 * 60 * 100);
    ds.setMaxIdleTime(30 * 60); // 30 minutes
    ds.setMaxStatements(10);
    ds.setMaxStatementsPerConnection(10);
    ds.setAutoCommitOnClose(true);

    ds.setDriverClass(environment.getRequiredProperty("nextrtc.db.driverClassName"));
    ds.setJdbcUrl(environment.getRequiredProperty("nextrtc.db.url"));
    ds.setUser(environment.getRequiredProperty("nextrtc.db.username"));
    ds.setPassword(environment.getRequiredProperty("nextrtc.db.password"));
    return ds;
}
 
开发者ID:mslosarz,项目名称:nextrtc-videochat-with-rest,代码行数:18,代码来源:DBConfig.java

示例4: configDataSource

import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
public static DataSource configDataSource(RepDatabase cfg)
		throws PropertyVetoException {

	ComboPooledDataSource ds = new ComboPooledDataSource();

	ds.setDriverClass(cfg.getDriverclass().trim());
	// loads the jdbc driver
	ds.setJdbcUrl(cfg.getUrl().trim());
	ds.setUser(cfg.getUsername().trim());
	ds.setPassword(cfg.getPassword().trim());
	ds.setMaxStatements(20);//
	ds.setMaxIdleTime(cfg.getMaxidletime());// 最大空闲时间,60秒内未使用则连接被丢弃。若为0则永不丢弃
	ds.setMaxPoolSize(cfg.getMaxpoolsize());// 池最大连接数
	ds.setMinPoolSize(cfg.getMinpoolsize());// 池最小连接数

	// 检查有效性
	if(StringHelper.isNotEmpty(cfg.getTestquerysql())&&cfg.getTestoeriod()!=null){
		ds.setPreferredTestQuery(cfg.getTestquerysql());
		ds.setIdleConnectionTestPeriod(cfg.getTestoeriod());// 每隔10分钟检查一次空闲连接的有效性
	}
	
	//获取连接超时
	ds.setCheckoutTimeout(10000);

	return ds;
}
 
开发者ID:leopardoooo,项目名称:cambodia,代码行数:27,代码来源:ConnContainer.java

示例5: setup

import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
@Override
    public SqlgDataSource setup(String driver, Configuration configuration) throws Exception {
        Preconditions.checkState(configuration.containsKey(SqlgGraph.JDBC_URL));
        Preconditions.checkState(configuration.containsKey("jdbc.username"));
        Preconditions.checkState(configuration.containsKey("jdbc.password"));
        String connectURI = configuration.getString(SqlgGraph.JDBC_URL);
        String username = configuration.getString("jdbc.username");
        String password = configuration.getString("jdbc.password");
        ComboPooledDataSource comboPooledDataSource = new ComboPooledDataSource();
        comboPooledDataSource.setDriverClass(driver);
        comboPooledDataSource.setJdbcUrl(connectURI);
        comboPooledDataSource.setMaxPoolSize(configuration.getInt("maxPoolSize", 100));
//        comboPooledDataSource.setInitialPoolSize(1);
//        comboPooledDataSource.setMinPoolSize(1);
//        comboPooledDataSource.setMaxPoolSize(1);
        comboPooledDataSource.setMaxIdleTime(configuration.getInt("maxIdleTime", 3600));
        comboPooledDataSource.setForceUseNamedDriverClass(true);
        if (!StringUtils.isEmpty(username)) {
            comboPooledDataSource.setUser(username);
        }
        if (!StringUtils.isEmpty(password)) {
            comboPooledDataSource.setPassword(password);
        }

        return new C3P0DataSource(connectURI, comboPooledDataSource);
    }
 
开发者ID:pietermartin,项目名称:sqlg,代码行数:27,代码来源:C3p0DataSourceFactory.java

示例6: wrap

import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
@Override
public DataSource wrap(ReportDataSource rptDs) {
    try {
        ComboPooledDataSource dataSource = new ComboPooledDataSource();
        dataSource.setDriverClass(rptDs.getDriverClass());
        dataSource.setJdbcUrl(rptDs.getJdbcUrl());
        dataSource.setUser(rptDs.getUser());
        dataSource.setPassword(rptDs.getPassword());
        dataSource.setInitialPoolSize(MapUtils.getInteger(rptDs.getOptions(), "initialPoolSize", 3));
        dataSource.setMinPoolSize(MapUtils.getInteger(rptDs.getOptions(), "minPoolSize", 1));
        dataSource.setMaxPoolSize(MapUtils.getInteger(rptDs.getOptions(), "maxPoolSize", 20));
        dataSource.setMaxStatements(MapUtils.getInteger(rptDs.getOptions(), "maxStatements", 50));
        dataSource.setMaxIdleTime(MapUtils.getInteger(rptDs.getOptions(), "maxIdleTime", 1800));
        dataSource.setAcquireIncrement(MapUtils.getInteger(rptDs.getOptions(), "acquireIncrement", 3));
        dataSource.setAcquireRetryAttempts(MapUtils.getInteger(rptDs.getOptions(), "acquireRetryAttempts", 30));
        dataSource.setIdleConnectionTestPeriod(
            MapUtils.getInteger(rptDs.getOptions(), "idleConnectionTestPeriod", 60));
        dataSource.setBreakAfterAcquireFailure(
            MapUtils.getBoolean(rptDs.getOptions(), "breakAfterAcquireFailure", false));
        dataSource.setTestConnectionOnCheckout(
            MapUtils.getBoolean(rptDs.getOptions(), "testConnectionOnCheckout", false));
        return dataSource;
    } catch (Exception ex) {
        throw new RuntimeException("C3p0DataSourcePool Create Error", ex);
    }
}
 
开发者ID:xianrendzw,项目名称:EasyReport,代码行数:27,代码来源:C3p0DataSourcePool.java

示例7: getConnection

import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
@Override
public synchronized Connection getConnection(Configuration conf) throws SQLException {
  DriverConfig config = getDriverConfigfromConf(conf);
  if (!dataSourceMap.containsKey(config)) {
    ComboPooledDataSource cpds = new ComboPooledDataSource();
    try {
      cpds.setDriverClass(config.driverClass);
    } catch (PropertyVetoException e) {
      throw new IllegalArgumentException("Unable to set driver class:" + config.driverClass, e);
    }
    cpds.setJdbcUrl(config.jdbcURI);
    cpds.setProperties(config.properties);

    cpds.setMaxPoolSize(Integer.parseInt(config.getProperty(JDBC_POOL_MAX_SIZE.getPoolProperty())));
    cpds.setMaxIdleTime(Integer.parseInt(config.getProperty(JDBC_POOL_IDLE_TIME.getPoolProperty())));
    cpds.setMaxIdleTimeExcessConnections(Integer.parseInt(config.getProperty(JDBC_MAX_IDLE_TIME_EXCESS_CONNECTIONS
      .getPoolProperty())));
    cpds.setMaxStatementsPerConnection(Integer.parseInt(config.getProperty(JDBC_MAX_STATEMENTS_PER_CONNECTION
      .getPoolProperty())));
    cpds.setCheckoutTimeout(Integer.parseInt(config.getProperty(JDBC_GET_CONNECTION_TIMEOUT.getPoolProperty())));
    dataSourceMap.put(config, cpds);
    log.info("Created new datasource for config: {}", config);
  }
  return dataSourceMap.get(config).getConnection();
}
 
开发者ID:apache,项目名称:lens,代码行数:26,代码来源:DataSourceConnectionProvider.java

示例8: getDataSource

import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
private DataSource getDataSource(C3P0 c3p0) throws Exception {
    ComboPooledDataSource ds = new ComboPooledDataSource(true);
    ds.setDataSourceName("C3PO");
    ds.setJdbcUrl(c3p0.jdbcUrl);
    ds.setDriverClass(c3p0.driverClass);
    ds.setUser(c3p0.user);
    ds.setPassword(c3p0.password);
    ds.setMaxIdleTime(c3p0.maxIdleTime);
    ds.setMaxPoolSize((c3p0.maxPoolSize));
    ds.setMinPoolSize(c3p0.minPoolSize);

    return ds;
}
 
开发者ID:linyuhe,项目名称:london,代码行数:14,代码来源:Resources.java

示例9: DAOFactory

import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
protected DAOFactory(String driverClassName, String jdbcURL, String userName, String userPassword, int initPoolSize,
        int MinPoolSize, int MaxPoolSize, int maxIdleTime, int idleConnectionTestPeriod, String testQuerySQL) {

    ds = new ComboPooledDataSource();
    // 设置JDBC的Driver类
    try {
        ds.setDriverClass(driverClassName);
    }
    catch (PropertyVetoException e) {
        throw new RuntimeException(e);
    }
    // 设置JDBC的URL
    ds.setJdbcUrl(jdbcURL);
    // 设置数据库的登录用户名
    ds.setUser(userName);
    // 设置数据库的登录用户密码
    ds.setPassword(userPassword);
    // 设置连接池的最大连接数
    ds.setMaxPoolSize(MaxPoolSize);
    // 设置连接池的最小连接数
    ds.setMinPoolSize(MinPoolSize);
    // 设置初始化连接数
    ds.setInitialPoolSize(initPoolSize);
    // 设置最大闲置时间
    ds.setMaxIdleTime(maxIdleTime);
    // 设置测试SQL
    ds.setPreferredTestQuery(testQuerySQL);
    // 设置闲置测试周期
    ds.setIdleConnectionTestPeriod(idleConnectionTestPeriod);

    // 增加单个连接的Statements数量
    ds.setMaxStatements(0);
    ds.setMaxStatementsPerConnection(200);

}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:36,代码来源:DAOFactory.java

示例10: DAOFactory

import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
protected DAOFactory(String facName, String driverClassName, String jdbcURL, String userName, String userPassword,
        int initPoolSize, int MinPoolSize, int MaxPoolSize, int maxIdleTime, int idleConnectionTestPeriod,
        String testQuerySQL) {

    this.facName = facName;

    ds = new ComboPooledDataSource();
    // 设置JDBC的Driver类
    try {
        ds.setDriverClass(driverClassName);
    }
    catch (PropertyVetoException e) {
        throw new RuntimeException(e);
    }
    // 设置JDBC的URL
    ds.setJdbcUrl(jdbcURL);
    // 设置数据库的登录用户名
    ds.setUser(userName);
    // 设置数据库的登录用户密码
    ds.setPassword(userPassword);
    // 设置连接池的最大连接数
    ds.setMaxPoolSize(MaxPoolSize);
    // 设置连接池的最小连接数
    ds.setMinPoolSize(MinPoolSize);
    // 设置初始化连接数
    ds.setInitialPoolSize(initPoolSize);
    // 设置最大闲置时间
    ds.setMaxIdleTime(maxIdleTime);
    // 设置测试SQL
    ds.setPreferredTestQuery(testQuerySQL);
    // 设置闲置测试周期
    ds.setIdleConnectionTestPeriod(idleConnectionTestPeriod);
    // 增加单个连接的Statements数量
    ds.setMaxStatements(0);
    // 连接池内单个连接所拥有的最大缓存statements数
    ds.setMaxStatementsPerConnection(200);
    // 获取空闲连接超时时间
    ds.setCheckoutTimeout(10 * 1000);
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:40,代码来源:DAOFactory.java

示例11: Initialize

import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
/**
 * Initializes the pool.
 *DriverClass - The JDBC driver class.
 *JdbcUrl - JDBC connection url.
 *User / Password - Connection credentials.
 */
public void Initialize(String DriverClass, String JdbcUrl, String User, String Password) throws PropertyVetoException {
	final ComboPooledDataSource pool = new ComboPooledDataSource();
	setObject(pool);
	pool.setDriverClass(DriverClass);
	pool.setJdbcUrl(JdbcUrl);
	pool.setUser(User);
	pool.setPassword(Password);
	pool.setMaxStatements(150);
	pool.setMaxIdleTime(1800);
	pool.setIdleConnectionTestPeriod(600);
	pool.setCheckoutTimeout(20000);
	pool.setTestConnectionOnCheckout(true);
}
 
开发者ID:AnywhereSoftware,项目名称:B4J_Server,代码行数:20,代码来源:ConnectionPool.java

示例12: createDataSource

import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
public static ProxyDataSource createDataSource(String driverClass, String jdbcUrl, String user, String password, int maxPoolSize) {
	if (StringUtils.isEmpty(driverClass)) {
		// System.err.println("驱动程序没有设置.");
		driverClass = "oracle.jdbc.driver.OracleDriver";
	}

	logger.info("createDataSource jdbcUrl:" + jdbcUrl);
	// ComboPooledDataSource dataSource = new ComboPooledDataSource();
	ComboPooledDataSource dataSource = new ComboPooledDataSource();
	try {
		// dataSource.setDriverClass("org.mariadb.jdbc.Driver");
		// dataSource.setDriverClass("org.gjt.mm.mysql.Driver");
		dataSource.setDriverClass(driverClass);
	}
	catch (PropertyVetoException e) {
		throw new RuntimeException(e.getMessage(), e);
	}
	dataSource.setJdbcUrl(jdbcUrl);
	dataSource.setUser(user);
	dataSource.setPassword(password);
	dataSource.setTestConnectionOnCheckout(false);
	dataSource.setInitialPoolSize(1);
	dataSource.setMinPoolSize(1);
	dataSource.setMaxPoolSize(maxPoolSize);
	dataSource.setAcquireIncrement(1);
	dataSource.setAcquireRetryAttempts(1);
	dataSource.setMaxIdleTime(7200);
	dataSource.setMaxStatements(0);
	return new OracleProxyDataSource(dataSource);
}
 
开发者ID:tanhaichao,项目名称:leopard,代码行数:31,代码来源:OracleProxyDataSource.java

示例13: start

import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
/**
 * 使用指定配置文件初始化 C3P0。
 * 
 * @param file
 *            配置文件路径
 */
public void start(String file) {
	if (isStarted) {
		return;
	}
	if (file.equals("")) {
		file = "dbconfig.properties";
	}
	init(file);

	dataSource = new ComboPooledDataSource();
	dataSource.setJdbcUrl(jdbcUrl);
	dataSource.setUser(user);
	dataSource.setPassword(password);
	try {
		dataSource.setDriverClass(driverClass);
	} catch (PropertyVetoException e) {
		dataSource = null;
		throw new RuntimeException(e);
	}
	dataSource.setMaxPoolSize(maxPoolSize);
	dataSource.setMinPoolSize(minPoolSize);
	dataSource.setInitialPoolSize(initialPoolSize);
	dataSource.setMaxIdleTime(maxIdleTime);
	dataSource.setAcquireIncrement(acquireIncrement);

	isStarted = true;
}
 
开发者ID:mastermay,项目名称:Spectre,代码行数:34,代码来源:C3p0.java

示例14: createDelegate

import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
@Override
protected DataSource createDelegate() {
    final ComboPooledDataSource ds = new ComboPooledDataSource();
    try {
        ds.setDriverClass(context.getConnectionDriver());
    } catch (final PropertyVetoException e1) {
        throw Err.process(e1);
    }
    ds.setJdbcUrl(context.getConnectionUrl());
    ds.setUser(context.getConnectionUser());
    ds.setPassword(context.getConnectionPassword());

    ds.setMaxStatements(5000);
    ds.setMaxStatementsPerConnection(50);
    ds.setStatementCacheNumDeferredCloseThreads(1); //fix apparent deadlocks

    ds.setMaxPoolSize(100);
    ds.setMinPoolSize(1);
    ds.setMaxIdleTime(new Duration(1, FTimeUnit.MINUTES).intValue(FTimeUnit.SECONDS));
    ds.setTestConnectionOnCheckout(true);

    ds.setAutoCommitOnClose(true);

    Assertions.assertThat(this.closeableDs).isNull();
    this.closeableDs = ds;

    if (logging) {
        try {
            final ConnectionPoolDataSourceProxy proxy = new ConnectionPoolDataSourceProxy();
            proxy.setTargetDSDirect(ds);
            return proxy;
        } catch (final JdbcDsLogRuntimeException e) {
            throw new RuntimeException(e);
        }
    } else {
        return ds;
    }
}
 
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:39,代码来源:ConfiguredCPDataSource.java

示例15: configure

import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
@Override
public void configure(ComboPooledDataSource ds) {
  ds.setMinPoolSize(poolSize);
  ds.setInitialPoolSize(poolSize);
  ds.setMaxPoolSize(poolSize * 3);
  ds.setAcquireIncrement(aquireInc);
  ds.setMaxIdleTime(maxIdle);
  ds.setMaxConnectionAge(maxAge);
  ds.setMaxStatementsPerConnection(maxStmts);
  ds.setAcquireRetryAttempts(retry);
  ds.setAcquireRetryDelay(retryDelay);
}
 
开发者ID:vvergnolle,项目名称:vas,代码行数:13,代码来源:AddressModule.java


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