Java Code Examples for bitronix.tm.resource.jdbc.PoolingDataSource

The following examples show how to use bitronix.tm.resource.jdbc.PoolingDataSource. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
public DataSource actualDataSource() {
    final PoolingDataSource poolingDataSource = (PoolingDataSource) super.actualDataSource();
    com.vladmihalcea.flexypool.config.Configuration<PoolingDataSource> configuration = new com.vladmihalcea.flexypool.config.Configuration.Builder<>(
        getClass().getSimpleName(), poolingDataSource, BitronixPoolAdapter.FACTORY).build();

    FlexyPoolDataSource<PoolingDataSource> flexyPoolDataSource = new FlexyPoolDataSource<PoolingDataSource>(configuration) {
        @Override
        public void start() {
            poolingDataSource.init();
            super.start();
        }

        @Override
        public void stop() {
            super.stop();
            poolingDataSource.close();
        }
    };
    return flexyPoolDataSource;
}
 
Example 2
Source Project: glowroot   Source File: Connections.java    License: Apache License 2.0 6 votes vote down vote up
static PoolingDataSource createBitronixWrappedDataSource() throws AssertionError {
    if (Connections.class.getClassLoader() instanceof IsolatedWeavingClassLoader) {
        throw new AssertionError("Bitronix loads JdbcProxyFactory implementation using a"
                + " parent-first class loader, which bypasses IsolatedWeavingClassLoader, must"
                + " use JavaagentContainer");
    }
    PoolingDataSource ds = new PoolingDataSource();
    ds.setClassName(JDBCXADataSource.class.getName());
    Properties props = new Properties();
    props.setProperty("url", "jdbc:hsqldb:mem:test");
    ds.setDriverProperties(props);
    ds.setMaxPoolSize(1);
    ds.setUniqueName("unique-name-" + nextUniqueNum++);
    ds.setAllowLocalTransactions(true);
    return ds;
}
 
Example 3
Source Project: flexy-pool   Source File: FlexyPoolConfiguration.java    License: Apache License 2.0 6 votes vote down vote up
@Bean
public Configuration<PoolingDataSource> configuration() {
    return new Configuration.Builder<PoolingDataSource>(
            uniqueId,
            poolingDataSource,
            BitronixPoolAdapter.FACTORY
    )
    .setMetricsFactory(MetricsFactoryResolver.INSTANCE.resolve())
    .setConnectionProxyFactory(ConnectionDecoratorFactoryResolver.INSTANCE.resolve())
    .setMetricLogReporterMillis(TimeUnit.SECONDS.toMillis(5))
    .setJmxEnabled(true)
    .setJmxAutoStart(true)
    .setConnectionAcquireTimeThresholdMillis(50L)
    .setConnectionLeaseTimeThresholdMillis(250L)
    .setEventListenerResolver(new EventListenerResolver() {
        @Override
        public List<EventListener<? extends Event>> resolveListeners() {
            return Arrays.<EventListener<? extends Event>>asList(
                new ConnectionAcquireTimeoutEventListener(),
                new ConnectionAcquireTimeThresholdExceededEventListener(),
                new ConnectionLeaseTimeThresholdExceededEventListener()
            );
        }
    })
    .build();
}
 
Example 4
Source Project: iaf   Source File: EsbUtils.java    License: Apache License 2.0 6 votes vote down vote up
private static PoolingDataSource setupJdbcDataSource(String url,
		String userName, String password) {
	log.debug("setting up JdbcDataSource url [" + url + "] username ["
			+ userName + "] password ["
			+ StringUtils.repeat("*", password.length()) + "]");
	PoolingDataSource jdbcDataSource = new PoolingDataSource();
	jdbcDataSource.setClassName("oracle.jdbc.xa.client.OracleXADataSource");
	jdbcDataSource.setUniqueName("oracle");
	jdbcDataSource.setMaxPoolSize(5);
	jdbcDataSource.setAllowLocalTransactions(true);
	// jdbcDataSource.setTestQuery("SELECT 1 FROM DUAL");
	jdbcDataSource.getDriverProperties().setProperty("user", userName);
	jdbcDataSource.getDriverProperties().setProperty("password", password);
	jdbcDataSource.getDriverProperties().setProperty("URL", url);
	jdbcDataSource.init();
	return jdbcDataSource;
}
 
Example 5
@Bean(destroyMethod = "close")
public PoolingDataSource actualDataSource() {
    PoolingDataSource poolingDataSource = new PoolingDataSource();
    poolingDataSource.setClassName(dataSourceClassName);
    poolingDataSource.setUniqueName(getClass().getName());
    poolingDataSource.setMinPoolSize(0);
    poolingDataSource.setMaxPoolSize(5);
    poolingDataSource.setAllowLocalTransactions(true);
    poolingDataSource.setDriverProperties(new Properties());
    poolingDataSource.getDriverProperties().put("user", jdbcUser);
    poolingDataSource.getDriverProperties().put("password", jdbcPassword);
    poolingDataSource.getDriverProperties().put("url", jdbcUrl);
    return poolingDataSource;
}
 
Example 6
public DataSource extraDataSource() {
    PoolingDataSource poolingDataSource = new PoolingDataSource();
    poolingDataSource.setClassName(dataSourceClassName);
    poolingDataSource.setUniqueName("ExtraDS");
    poolingDataSource.setMinPoolSize(0);
    poolingDataSource.setMaxPoolSize(5);
    poolingDataSource.setAllowLocalTransactions(true);
    poolingDataSource.setDriverProperties(new Properties());
    poolingDataSource.getDriverProperties().put("user", jdbcUser);
    poolingDataSource.getDriverProperties().put("password", jdbcPassword);
    poolingDataSource.getDriverProperties().put("databaseName", jdbcDatabase);
    poolingDataSource.getDriverProperties().put("serverName", jdbcHost);
    poolingDataSource.getDriverProperties().put("portNumber", jdbcPort);
    return poolingDataSource;
}
 
Example 7
public DataSource actualDataSource() {
    PoolingDataSource poolingDataSource = new PoolingDataSource();
    poolingDataSource.setClassName(dataSourceClassName);
    poolingDataSource.setUniqueName(getClass().getName());
    poolingDataSource.setMinPoolSize(0);
    poolingDataSource.setMaxPoolSize(5);
    poolingDataSource.setAllowLocalTransactions(true);
    poolingDataSource.setDriverProperties(new Properties());
    poolingDataSource.getDriverProperties().put("user", jdbcUser);
    poolingDataSource.getDriverProperties().put("password", jdbcPassword);
    poolingDataSource.getDriverProperties().put("url", jdbcUrl);
    return poolingDataSource;
}
 
Example 8
public DataSource actualDataSource() {
    PoolingDataSource poolingDataSource = new PoolingDataSource();
    poolingDataSource.setClassName(dataSourceClassName);
    poolingDataSource.setUniqueName(getClass().getName());
    poolingDataSource.setMinPoolSize(0);
    poolingDataSource.setMaxPoolSize(5);
    poolingDataSource.setAllowLocalTransactions(true);
    poolingDataSource.setDriverProperties(new Properties());
    poolingDataSource.getDriverProperties().put("user", jdbcUser);
    poolingDataSource.getDriverProperties().put("password", jdbcPassword);
    poolingDataSource.getDriverProperties().put("databaseName", jdbcDatabase);
    poolingDataSource.getDriverProperties().put("serverName", jdbcHost);
    poolingDataSource.getDriverProperties().put("portNumber", jdbcPort);
    return poolingDataSource;
}
 
Example 9
Source Project: flexy-pool   Source File: FlexyPoolConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Bean(initMethod = "start", destroyMethod = "stop")
public FlexyPoolDataSource dataSource() {
    Configuration<PoolingDataSource> configuration = configuration();
    return new FlexyPoolDataSource<PoolingDataSource>(configuration,
            new IncrementPoolOnTimeoutConnectionAcquiringStrategy.Factory(5),
            new RetryConnectionAcquiringStrategy.Factory(2)
    );
}
 
Example 10
public void setDataSource(PoolingDataSource dataSource) {
  this.dataSource = dataSource;
}
 
Example 11
@Override
public Class<?> getObjectType() {
  return PoolingDataSource.class;
}
 
Example 12
public void setDataSource(PoolingDataSource dataSource) {
  this.dataSource = dataSource;
}
 
Example 13
@Override
public Class<?> getObjectType() {
  return PoolingDataSource.class;
}
 
Example 14
public void setDataSource(PoolingDataSource dataSource) {
    this.dataSource = dataSource;
}
 
Example 15
@Override
public Class<?> getObjectType() {
    return PoolingDataSource.class;
}
 
Example 16
public void setDataSource(PoolingDataSource dataSource) {
    this.dataSource = dataSource;
}
 
Example 17
@Override
public Class<?> getObjectType() {
    return PoolingDataSource.class;
}
 
Example 18
Source Project: flexy-pool   Source File: BitronixPoolAdapter.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public PoolAdapter<PoolingDataSource> newInstance(
        ConfigurationProperties<PoolingDataSource, Metrics, PoolAdapter<PoolingDataSource>> configurationProperties) {
return new BitronixPoolAdapter(configurationProperties);
}
 
Example 19
Source Project: flexy-pool   Source File: BitronixPoolAdapter.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Init constructor
 * @param configurationProperties configuration properties
 */
public BitronixPoolAdapter(ConfigurationProperties<PoolingDataSource, Metrics, PoolAdapter<PoolingDataSource>> configurationProperties) {
    super(configurationProperties);
}