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


Java ComboPooledDataSource.setConnectionCustomizerClassName方法代码示例

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


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

示例1: createC3P0DataSource

import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
private DataSource createC3P0DataSource() throws PropertyVetoException {
    ComboPooledDataSource ds = new ComboPooledDataSource();
    ds.setDriverClass(configuration.getDriverClassName());
    ds.setJdbcUrl(configuration.getJdbcUrl());
    ds.setUser(configuration.getJdbcUsername());
    ds.setPassword(configuration.getJdbcPassword());

    ds.setAcquireIncrement(3);
    ds.setMinPoolSize(configuration.getMinPoolSize());
    ds.setMaxPoolSize(configuration.getMaxPoolSize());
    ds.setIdleConnectionTestPeriod(1800);
    ds.setConnectionTesterClassName(MidPointConnectionTester.class.getName());
    ds.setConnectionCustomizerClassName(MidPointConnectionCustomizer.class.getName());

    return ds;
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:17,代码来源:DataSourceFactory.java

示例2: setupDataSource

import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static void setupDataSource(Isolation isolation) {
  ds = new ComboPooledDataSource();
  Endpoint locatorEndPoint = (Endpoint) (NetworkServerHelper.getNetworkLocatorEndpoints()).get(0);
  String hostname = getHostNameFromEndpoint(locatorEndPoint);
  int port = getPortFromEndpoint(locatorEndPoint); 
  
  connProp.putAll(getExtraConnProp()); //singlehop conn properties and any additional prop
  
  try {
    ds.setProperties(connProp); 
    ds.setDriverClass(driver);
    ds.setJdbcUrl(protocol + hostname+ ":" + port);
    
    ds.setMinPoolSize(5);
    ds.setAcquireIncrement(5);
    ds.setMaxPoolSize(numOfWorkers + 100);
    ds.setMaxStatementsPerConnection(10);
    
    if (isolation == Isolation.NONE) {
      ds.setConnectionCustomizerClassName( "sql.sqlutil.MyConnectionCustomizer");
    } else if (isolation == Isolation.READ_COMMITTED) {
      ds.setConnectionCustomizerClassName("sql.sqlutil.IsolationRCConnectionCustomizer");
    } else {
      ds.setConnectionCustomizerClassName("sql.sqlutil.IsolationRRConnectionCustomizer");
    }
    
    Log.getLogWriter().info("Pooled data source url is set as " + ds.getJdbcUrl());
    
    StringBuilder sb = new StringBuilder();
    
    for (Iterator iter = connProp.entrySet().iterator(); iter.hasNext(); ) {
      Map.Entry<String, String> entry = (Map.Entry<String, String>) iter.next();
      
      sb.append(entry.getKey() + " is set to " + entry.getValue() +"\n");
    }
    
    Log.getLogWriter().info("Pooled data source setting the following connection prop: " + sb.toString());
    
  } catch (Exception e) {
    throw new TestException("could not set data source" + TestHelper.getStackTrace(e));
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:44,代码来源:PooledConnectionC3P0.java

示例3: createDataSource

import com.mchange.v2.c3p0.ComboPooledDataSource; //导入方法依赖的package包/类
/**
 * Creates {@link DataSource} based on {@link CConnection} properties.
 *
 * NOTE: this method never throws exception but just logs it.
 *
 * @param connection
 * @return {@link DataSource} or <code>null</code> if it cannot be created
 */
private ComboPooledDataSource createDataSource(final CConnection connection)
{
	try
	{
		System.setProperty("com.mchange.v2.log.MLog", com.mchange.v2.log.slf4j.Slf4jMLog.class.getName());
		// System.setProperty("com.mchange.v2.log.FallbackMLog.DEFAULT_CUTOFF_LEVEL", "ALL");
		final ComboPooledDataSource cpds = new ComboPooledDataSource();
		cpds.setDataSourceName("AdempiereDS");
		cpds.setDriverClass(DRIVER);
		// loads the jdbc driver
		cpds.setJdbcUrl(getConnectionURL(connection));
		cpds.setUser(connection.getDbUid());
		cpds.setPassword(connection.getDbPwd());
		cpds.setPreferredTestQuery(DEFAULT_CONN_TEST_SQL);
		cpds.setIdleConnectionTestPeriod(1200);
		// cpds.setTestConnectionOnCheckin(true);
		// cpds.setTestConnectionOnCheckout(true);
		cpds.setAcquireRetryAttempts(2);

		// Set checkout timeout to avoid forever locking when trying to connect to a not existing host.
		cpds.setCheckoutTimeout(SystemUtils.getSystemProperty(CONFIG_CheckoutTimeout, 20 * 1000));

		if (Ini.isClient())
		{
			cpds.setInitialPoolSize(1);
			cpds.setMinPoolSize(1);
			cpds.setMaxPoolSize(20);
			cpds.setMaxIdleTimeExcessConnections(1200);
			cpds.setMaxIdleTime(900);
			m_maxbusyconnectionsThreshold = 15;
		}
		else
		{
			cpds.setInitialPoolSize(10);
			cpds.setMinPoolSize(5);
			cpds.setMaxPoolSize(150);
			cpds.setMaxIdleTimeExcessConnections(1200);
			cpds.setMaxIdleTime(1200);
			m_maxbusyconnectionsThreshold = 120;
		}

		// the following sometimes kill active connection!
		// cpds.setUnreturnedConnectionTimeout(1200);
		// cpds.setDebugUnreturnedConnectionStackTraces(true);

		// 04006: add a customizer to set the log level for message that are send to the client
		// background: if there are too many messages sent (e.g. from a verbose and long-running DB function)
		// then the whole JVM might suffer an OutOfMemoryError
		cpds.setConnectionCustomizerClassName(DB_PostgreSQL_ConnectionCustomizer.class.getName());

		return cpds;
	}
	catch (Exception ex)
	{
		throw new DBNoConnectionException("Could not initialise C3P0 Datasource", ex);
	}
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:66,代码来源:DB_PostgreSQL.java


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