use of com.zaxxer.hikari.HikariDataSource in project storm by apache.
the class HikariCPConnectionProvider method prepare.
@Override
public synchronized void prepare() {
if (dataSource == null) {
Properties properties = new Properties();
properties.putAll(configMap);
HikariConfig config = new HikariConfig(properties);
if (properties.containsKey("dataSource.url")) {
LOG.info("DataSource Url: " + properties.getProperty("dataSource.url"));
} else if (config.getJdbcUrl() != null) {
LOG.info("JDBC Url: " + config.getJdbcUrl());
}
this.dataSource = new HikariDataSource(config);
this.dataSource.setAutoCommit(false);
}
}
use of com.zaxxer.hikari.HikariDataSource in project hive by apache.
the class TxnHandler method setupJdbcConnectionPool.
private static synchronized void setupJdbcConnectionPool(HiveConf conf) throws SQLException {
if (connPool != null)
return;
String driverUrl = HiveConf.getVar(conf, HiveConf.ConfVars.METASTORECONNECTURLKEY);
String user = getMetastoreJdbcUser(conf);
String passwd = getMetastoreJdbcPasswd(conf);
String connectionPooler = conf.getVar(HiveConf.ConfVars.METASTORE_CONNECTION_POOLING_TYPE).toLowerCase();
if ("bonecp".equals(connectionPooler)) {
BoneCPConfig config = new BoneCPConfig();
config.setJdbcUrl(driverUrl);
//if we are waiting for connection for 60s, something is really wrong
//better raise an error than hang forever
config.setConnectionTimeoutInMs(60000);
config.setMaxConnectionsPerPartition(10);
config.setPartitionCount(1);
config.setUser(user);
config.setPassword(passwd);
connPool = new BoneCPDataSource(config);
// Enable retries to work around BONECP bug.
doRetryOnConnPool = true;
} else if ("dbcp".equals(connectionPooler)) {
ObjectPool objectPool = new GenericObjectPool();
ConnectionFactory connFactory = new DriverManagerConnectionFactory(driverUrl, user, passwd);
// This doesn't get used, but it's still necessary, see
// http://svn.apache.org/viewvc/commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/doc/ManualPoolingDataSourceExample.java?view=markup
PoolableConnectionFactory poolConnFactory = new PoolableConnectionFactory(connFactory, objectPool, null, null, false, true);
connPool = new PoolingDataSource(objectPool);
} else if ("hikaricp".equals(connectionPooler)) {
HikariConfig config = new HikariConfig();
config.setJdbcUrl(driverUrl);
config.setUsername(user);
config.setPassword(passwd);
connPool = new HikariDataSource(config);
} else if ("none".equals(connectionPooler)) {
LOG.info("Choosing not to pool JDBC connections");
connPool = new NoPoolConnectionPool(conf);
} else {
throw new RuntimeException("Unknown JDBC connection pooling " + connectionPooler);
}
}
use of com.zaxxer.hikari.HikariDataSource in project jOOQ by jOOQ.
the class SakilaReportService method initDB.
private static void initDB() throws Exception {
final Properties properties = new Properties();
properties.load(SakilaReportService.class.getResourceAsStream("/config.properties"));
Class.forName(properties.getProperty("db.driver"));
HikariDataSource ds = new HikariDataSource();
ds.setJdbcUrl(properties.getProperty("db.url"));
ds.setUsername(properties.getProperty("db.username"));
ds.setPassword(properties.getProperty("db.password"));
// Some nice debug logging of formatted queries and the first 5 rows in each result set.
dsl = DSL.using(new DefaultConfiguration().set(ds).set(DefaultExecuteListenerProvider.providers(new DefaultExecuteListener() {
@Override
public void executeEnd(ExecuteContext ctx) {
Configuration config = ctx.configuration().derive();
config.settings().setRenderFormatted(true);
log.info("\n" + DSL.using(config).renderInlined(ctx.query()));
}
@Override
public void fetchEnd(ExecuteContext ctx) {
log.info("\n" + ctx.result().format(5));
}
})));
}
use of com.zaxxer.hikari.HikariDataSource in project killbill by killbill.
the class TestKillbillJdbcTenantRealm method beforeMethod.
@Override
@BeforeMethod(groups = "slow")
public void beforeMethod() throws Exception {
super.beforeMethod();
// Create the tenant
final DefaultTenantDao tenantDao = new DefaultTenantDao(dbi, clock, cacheControllerDispatcher, new DefaultNonEntityDao(dbi), Mockito.mock(InternalCallContextFactory.class), securityConfig);
tenant = new DefaultTenant(UUID.randomUUID(), null, null, UUID.randomUUID().toString(), UUID.randomUUID().toString(), UUID.randomUUID().toString());
tenantDao.create(new TenantModelDao(tenant), internalCallContext);
// Setup the security manager
final HikariConfig dbConfig = new HikariConfig();
dbConfig.setJdbcUrl(helper.getJdbcConnectionString());
dbConfig.setUsername(helper.getUsername());
dbConfig.setPassword(helper.getPassword());
final KillbillJdbcTenantRealm jdbcRealm = new KillbillJdbcTenantRealm(shiroDataSource, securityConfig);
jdbcRealm.setDataSource(new HikariDataSource(dbConfig));
securityManager = new DefaultSecurityManager(jdbcRealm);
}
use of com.zaxxer.hikari.HikariDataSource in project hibernate-orm by hibernate.
the class HikariCPConnectionProvider method configure.
// *************************************************************************
// Configurable
// *************************************************************************
@SuppressWarnings("rawtypes")
@Override
public void configure(Map props) throws HibernateException {
try {
LOGGER.debug("Configuring HikariCP");
hcfg = HikariConfigurationUtil.loadConfiguration(props);
hds = new HikariDataSource(hcfg);
} catch (Exception e) {
throw new HibernateException(e);
}
LOGGER.debug("HikariCP Configured");
}
Aggregations