當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。