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


Java ComboPooledDataSource.setAutoCommitOnClose方法代码示例

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


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

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

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

示例3: configureDB

import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
private void configureDB() throws Exception {
			
	if (props.getProperty("db.driver") != null) {			 
		// read app.conf to get these values
		ComboPooledDataSource cpds = new ComboPooledDataSource();
		cpds.setDriverClass( props.getProperty("db.driver").trim() ); //loads the jdbc driver            
		cpds.setJdbcUrl( props.getProperty("db.url").trim() );
		cpds.setUser( props.getProperty("db.user").trim() );                                  
		cpds.setPassword( props.getProperty("db.pass").trim() ); 
		cpds.setAutoCommitOnClose(true);
		
		DB.pds = cpds;
	}
}
 
开发者ID:codemwnci,项目名称:qrest,代码行数:15,代码来源:ApplicationBootstrap.java

示例4: L2DatabaseFactory

import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
public L2DatabaseFactory() throws SQLException
{
	try
	{
		if (Config.DATABASE_MAX_CONNECTIONS < 2)
           {
               Config.DATABASE_MAX_CONNECTIONS = 2;
               _log.warning("at least " + Config.DATABASE_MAX_CONNECTIONS + " db connections are required.");
           }

		_source = new ComboPooledDataSource();
		_source.setAutoCommitOnClose(true);

		_source.setInitialPoolSize(10);
		_source.setMinPoolSize(10);
		_source.setMaxPoolSize(Config.DATABASE_MAX_CONNECTIONS);

		_source.setAcquireRetryAttempts(0); // try to obtain connections indefinitely (0 = never quit)
		_source.setAcquireRetryDelay(500);  // 500 miliseconds wait before try to acquire connection again
		_source.setCheckoutTimeout(0);      // 0 = wait indefinitely for new connection
		// if pool is exhausted
		_source.setAcquireIncrement(5);     // if pool is exhausted, get 5 more connections at a time
		// cause there is a "long" delay on acquire connection
		// so taking more than one connection at once will make connection pooling
		// more effective.

		// this "connection_test_table" is automatically created if not already there
		_source.setAutomaticTestTable("connection_test_table");
		_source.setTestConnectionOnCheckin(false);

		// testing OnCheckin used with IdleConnectionTestPeriod is faster than  testing on checkout

		_source.setIdleConnectionTestPeriod(3600); // test idle connection every 60 sec
		_source.setMaxIdleTime(0); // 0 = idle connections never expire
		// *THANKS* to connection testing configured above
		// but I prefer to disconnect all connections not used
		// for more than 1 hour

		// enables statement caching,  there is a "semi-bug" in c3p0 0.9.0 but in 0.9.0.2 and later it's fixed
		_source.setMaxStatementsPerConnection(100);

		_source.setBreakAfterAcquireFailure(false);  // never fail if any way possible
		// setting this to true will make
		// c3p0 "crash" and refuse to work
		// till restart thus making acquire
		// errors "FATAL" ... we don't want that
		// it should be possible to recover
		_source.setDriverClass(Config.DATABASE_DRIVER);
		_source.setJdbcUrl(Config.DATABASE_URL);
		_source.setUser(Config.DATABASE_LOGIN);
		_source.setPassword(Config.DATABASE_PASSWORD);

		/* Test the connection */
		_source.getConnection().close();

		if (Config.DEBUG) _log.fine("Database Connection Working");

		if (Config.DATABASE_DRIVER.toLowerCase().contains("microsoft"))
               _providerType = ProviderType.MsSql;
           else
               _providerType = ProviderType.MySql;
	}
	catch (SQLException x)
	{
		if (Config.DEBUG) _log.fine("Database Connection FAILED");
		// rethrow the exception
		throw x;
	}
	catch (Exception e)
	{
		if (Config.DEBUG) _log.fine("Database Connection FAILED");
		throw new SQLException("could not init DB connection:"+e);
	}
}
 
开发者ID:L2jBrasil,项目名称:L2jBrasil,代码行数:75,代码来源:L2DatabaseFactory.java


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