Search in sources :

Example 6 with PoolingDataSource

use of org.datanucleus.store.rdbms.datasource.dbcp2.PoolingDataSource in project cloudstack by apache.

the class TransactionLegacy method getDefaultDataSource.

@SuppressWarnings({ "unchecked", "rawtypes" })
private static DataSource getDefaultDataSource(final String database) {
    final ConnectionFactory connectionFactory = new DriverManagerConnectionFactory("jdbc:mysql://localhost:3306/" + database, "cloud", "cloud");
    final PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory, null);
    final GenericObjectPool connectionPool = new GenericObjectPool(poolableConnectionFactory);
    return new PoolingDataSource(connectionPool);
}
Also used : ConnectionFactory(org.apache.commons.dbcp2.ConnectionFactory) DriverManagerConnectionFactory(org.apache.commons.dbcp2.DriverManagerConnectionFactory) PoolableConnectionFactory(org.apache.commons.dbcp2.PoolableConnectionFactory) PoolingDataSource(org.apache.commons.dbcp2.PoolingDataSource) DriverManagerConnectionFactory(org.apache.commons.dbcp2.DriverManagerConnectionFactory) GenericObjectPool(org.apache.commons.pool2.impl.GenericObjectPool) PoolableConnectionFactory(org.apache.commons.dbcp2.PoolableConnectionFactory)

Aggregations

PoolingDataSource (org.apache.commons.dbcp2.PoolingDataSource)5 ConnectionFactory (org.apache.commons.dbcp2.ConnectionFactory)4 PoolableConnectionFactory (org.apache.commons.dbcp2.PoolableConnectionFactory)4 GenericObjectPool (org.apache.commons.pool2.impl.GenericObjectPool)4 Properties (java.util.Properties)2 DriverManagerConnectionFactory (org.apache.commons.dbcp2.DriverManagerConnectionFactory)2 PoolableConnection (org.apache.commons.dbcp2.PoolableConnection)2 HikariDataSource (com.zaxxer.hikari.HikariDataSource)1 URI (java.net.URI)1 SQLException (java.sql.SQLException)1 Map (java.util.Map)1 DataSource (javax.sql.DataSource)1 BasicDataSource (org.apache.commons.dbcp2.BasicDataSource)1 DataSourceConnectionFactory (org.apache.commons.dbcp2.DataSourceConnectionFactory)1 GenericObjectPoolConfig (org.apache.commons.pool2.impl.GenericObjectPoolConfig)1 DatabaseProduct (org.apache.hadoop.hive.metastore.DatabaseProduct)1 MetastoreUnitTest (org.apache.hadoop.hive.metastore.annotation.MetastoreUnitTest)1 ConnectionFactory (org.datanucleus.store.rdbms.datasource.dbcp2.ConnectionFactory)1 DriverManagerConnectionFactory (org.datanucleus.store.rdbms.datasource.dbcp2.DriverManagerConnectionFactory)1 PoolableConnection (org.datanucleus.store.rdbms.datasource.dbcp2.PoolableConnection)1