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


Java DataSourceConnectionFactory类代码示例

本文整理汇总了Java中org.apache.commons.dbcp2.DataSourceConnectionFactory的典型用法代码示例。如果您正苦于以下问题:Java DataSourceConnectionFactory类的具体用法?Java DataSourceConnectionFactory怎么用?Java DataSourceConnectionFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: SqlCache

import org.apache.commons.dbcp2.DataSourceConnectionFactory; //导入依赖的package包/类
/**
 * Constructor.
 * 
 * @param dataSource
 *        The data source
 * @param maxSize
 *        The max entry count
 * @param poolSize
 *        The number of connections in the pool
 * @param lockSource
 *        The lock source
 */
public SqlCache( DataSource dataSource, int maxSize, int poolSize, LockSource lockSource )
{
	this.maxSize = maxSize;
	this.lockSource = lockSource;

	GenericObjectPoolConfig config = new GenericObjectPoolConfig();
	config.setMaxTotal( poolSize );
	config.setMaxIdle( poolSize );
	config.setMinIdle( poolSize );
	DataSourceConnectionFactory connectionFactory = new DataSourceConnectionFactory( dataSource );
	PoolableConnectionFactory pooledObjectFactory = new PoolableConnectionFactory( connectionFactory, null );
	GenericObjectPool<PoolableConnection> pool = new GenericObjectPool<PoolableConnection>( pooledObjectFactory, config );
	pooledObjectFactory.setPool( pool );
	this.dataSource = new PoolingDataSource<PoolableConnection>( pool );
}
 
开发者ID:tliron,项目名称:prudence,代码行数:28,代码来源:SqlCache.java

示例2: createConnectionFactory

import org.apache.commons.dbcp2.DataSourceConnectionFactory; //导入依赖的package包/类
@Override
protected ConnectionFactory createConnectionFactory() throws SQLException {
    if (delegate != null) {
        if (XADataSource.class.isInstance(delegate)) {
            return new DataSourceXAConnectionFactory(OpenEJB.getTransactionManager(), XADataSource.class.cast(delegate), getUsername(), getPassword());
        }
        return new DataSourceConnectionFactory(DataSource.class.cast(delegate), getUsername(), getPassword());
    }
    return super.createConnectionFactory();
}
 
开发者ID:apache,项目名称:tomee,代码行数:11,代码来源:BasicDataSource.java

示例3: createConnectionFactory

import org.apache.commons.dbcp2.DataSourceConnectionFactory; //导入依赖的package包/类
/**
 * Creating a connection factory based on the provided DataSource.
 */
@Override
protected ConnectionFactory createConnectionFactory() throws SQLException {
    return new DataSourceConnectionFactory(nonPoolingDataSource);
}
 
开发者ID:everit-org,项目名称:commons-dbcp-ds,代码行数:8,代码来源:BasicSimpleDataSource.java

示例4: createConnectionFactory

import org.apache.commons.dbcp2.DataSourceConnectionFactory; //导入依赖的package包/类
@Override
protected ConnectionFactory createConnectionFactory() throws SQLException {
    return new DataSourceConnectionFactory(this.ds, getUsername(), getPassword());
}
 
开发者ID:apache,项目名称:tomee,代码行数:5,代码来源:DbcpDataSource.java


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