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


Java DataSource.createPool方法代码示例

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


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

示例1: createDataSource

import org.apache.tomcat.jdbc.pool.DataSource; //导入方法依赖的package包/类
@Override
public DataSource createDataSource(Properties properties, Context context, boolean xa) throws SQLException {
    PoolConfiguration poolProperties = EncryptedDataSourceFactory.parsePoolProperties(properties);
    poolProperties.setPassword(decode(poolProperties.getPassword()));
    if (poolProperties.getDataSourceJNDI() != null && poolProperties.getDataSource() == null) {
        performJNDILookup(context, poolProperties);
    }
    DataSource dataSource = xa ? new XADataSource(poolProperties) : new DataSource(poolProperties);
    dataSource.createPool();

    return dataSource;
}
 
开发者ID:Sewatech,项目名称:swutils,代码行数:13,代码来源:EncryptedDataSourceFactory.java

示例2: testCloseDataSource

import org.apache.tomcat.jdbc.pool.DataSource; //导入方法依赖的package包/类
@Test
public void testCloseDataSource() throws Exception {
    TomcatJdbcDataSourceFactory tomcatJdbcDataSourceFactory = new TomcatJdbcDataSourceFactory();
    tomcatJdbcDataSourceFactory.setInitialSize(0);

    DataSourceInformation dataSourceInformation = new DataSourceInformation(DatabaseType.MYSQL,
            "localhost", 3306, "test", "user", "password");
    DataSource dataSource = tomcatJdbcDataSourceFactory.createDataSource(dataSourceInformation);
    assertNotNull(dataSource);

    ConnectionPool pool = dataSource.createPool();
    assertFalse(pool.isClosed());
    tomcatJdbcDataSourceFactory.closeDataSource(dataSource);
    assertTrue(pool.isClosed());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:16,代码来源:TomcatJdbcDataSourceFactoryTest.java

示例3: setup

import org.apache.tomcat.jdbc.pool.DataSource; //导入方法依赖的package包/类
@Before
public void setup() throws SQLException, StorageException {
    dataSource = new DataSource();
    dataSource.setDriverClassName(databaseClass);
    dataSource.setUrl(databaseUrl);
    dataSource.createPool();

    dbi = new DBI(dataSource);

    snapshotsStore = new OnDiskSnapshotsStore(dbi, snapshotsDirectory.getAbsolutePath());
    snapshotsStore.initialize();
}
 
开发者ID:allengeorge,项目名称:libraft,代码行数:13,代码来源:OnDiskSnapshotsStoreTest.java

示例4: start

import org.apache.tomcat.jdbc.pool.DataSource; //导入方法依赖的package包/类
@Override
public void start() {
	PoolProperties p = new PoolProperties();
	p.setUrl(this.conURL);
	p.setDriverClassName(this.driverName);
	p.setUsername(this.username);
	p.setPassword(this.password);
	p.setJmxEnabled(false);
	if (this.testSql != null && this.testSql.trim().length() > 0) {
		p.setValidationQuery(this.testSql);
		p.setTestWhileIdle(true);
		p.setTimeBetweenEvictionRunsMillis(15 * 1000);
		boolean tbf = AppProperties.getAsBoolean(
				"TomcatJdbcPool_TestOnBorrow", false);
		p.setTestOnBorrow(tbf);// 获取之前是否校验
		p.setTestOnReturn(false);
		p.setValidationInterval(30000);
	}
	p.setMaxActive(this.max);
	p.setMaxIdle(this.max);
	p.setInitialSize(this.min);
	p.setMinIdle(min);
	int maxwaitfornoconn = AppProperties.getAsInt("TomcatJdbcPool_MaxWait",
			30 * 1000);
	p.setMaxWait(maxwaitfornoconn);
	boolean removeAbandonedFlag = AppProperties.getAsBoolean(
			"TomcatJdbcPool_RemoveAbandoned", false);
	if (removeAbandonedFlag) {
		p.setLogAbandoned(true);
		p.setRemoveAbandoned(true);
		p.setRemoveAbandonedTimeout(AppProperties.getAsInt(
				"TomcatJdbcPool_RemoveAbandonedTimeout", 60));
	}
	// p.setMinEvictableIdleTimeMillis(30000);
	p.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;"
			+ "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer");
	datasource = new DataSource();
	datasource.setPoolProperties(p);
	try {
		datasource.createPool();
	} catch (SQLException e) {
		datasource.close();
		throw new AppRuntimeException("start tomcat pool err", e);
	}
}
 
开发者ID:jbeetle,项目名称:BJAF3.x,代码行数:46,代码来源:TomcatJdbcPool.java


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