本文整理汇总了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 );
}
示例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();
}
示例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);
}
示例4: createConnectionFactory
import org.apache.commons.dbcp2.DataSourceConnectionFactory; //导入依赖的package包/类
@Override
protected ConnectionFactory createConnectionFactory() throws SQLException {
return new DataSourceConnectionFactory(this.ds, getUsername(), getPassword());
}