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


Java PoolingDataSource类代码示例

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


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

示例1: createDataSource

import bitronix.tm.resource.jdbc.PoolingDataSource; //导入依赖的package包/类
@Override
public DataSource createDataSource(IsolationLevel isolationLevel, Class<?> qualifier,
        Consumer<Closeable> closeableRegistrar) {
    Properties props = new Properties();
    initializeProperties(props);

    PoolingDataSource btmDataSource = new PoolingDataSource();
    btmDataSource.setUniqueName((qualifier == null ? "" : qualifier.getSimpleName()) + "_" + isolationLevel.name());
    btmDataSource.setClassName(databaseIntegrationInfo.getDataSourceClass().getName());
    btmDataSource.setIsolationLevel(isolationLevel.name());
    btmDataSource.setDriverProperties(props);
    btmDataSource.setShareTransactionConnections(true);
    btmDataSource.setMaxPoolSize(10);
    btmDataSource.setAllowLocalTransactions(true);
    btmDataSource.setMinPoolSize(1);
    customizeDataSource(btmDataSource);

    closeableRegistrar.accept(btmDataSource::close);
    return new P6DataSource(btmDataSource);
}
 
开发者ID:ruediste,项目名称:rise,代码行数:21,代码来源:BitronixDataSourceFactory.java

示例2: actualDataSource

import bitronix.tm.resource.jdbc.PoolingDataSource; //导入依赖的package包/类
@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;
}
 
开发者ID:vladmihalcea,项目名称:high-performance-java-persistence,代码行数:22,代码来源:JTAFlexyPoolTestConfiguration.java

示例3: configuration

import bitronix.tm.resource.jdbc.PoolingDataSource; //导入依赖的package包/类
@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();
}
 
开发者ID:vladmihalcea,项目名称:flexy-pool,代码行数:27,代码来源:FlexyPoolConfiguration.java

示例4: setupWithPoolingDataSource

import bitronix.tm.resource.jdbc.PoolingDataSource; //导入依赖的package包/类
/**
 * This method does all of the setup for the test and returns a HashMap
 * containing the persistence objects that the test might need.
 * 
 * @param persistenceUnitName
 *            The name of the persistence unit used by the test.
 * @return HashMap<String Object> with persistence objects, such as the
 *         EntityManagerFactory and DataSource
 */
public static HashMap<String, Object> setupWithPoolingDataSource(final String persistenceUnitName, String dataSourceName, final boolean testMarshalling) {
    HashMap<String, Object> context = new HashMap<String, Object>();

    // set the right jdbc url
    Properties dsProps = getDatasourceProperties();
    String jdbcUrl = dsProps.getProperty("url");
    String driverClass = dsProps.getProperty("driverClassName");

    // Setup the datasource
    PoolingDataSource ds1 = setupPoolingDataSource(dsProps, dataSourceName);
    if( driverClass.startsWith("org.h2") ) { 
        jdbcUrl += "tcp://localhost/target/drools-persistence-test";
        ds1.getDriverProperties().setProperty("url", jdbcUrl);
    }
    ds1.init();
    context.put(DATASOURCE, ds1);

    // Setup persistence
    EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnitName);
    context.put(ENTITY_MANAGER_FACTORY, emf);

    return context;
}
 
开发者ID:mrietveld,项目名称:gimcrack,代码行数:33,代码来源:PersistenceUtil.java

示例5: setupJdbcDataSource

import bitronix.tm.resource.jdbc.PoolingDataSource; //导入依赖的package包/类
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;
}
 
开发者ID:ibissource,项目名称:iaf,代码行数:18,代码来源:EsbUtils.java

示例6: batchMetaDataDataSource

import bitronix.tm.resource.jdbc.PoolingDataSource; //导入依赖的package包/类
@Bean(initMethod = "init", destroyMethod = "close")
public PoolingDataSource batchMetaDataDataSource() {
	PoolingDataSource ds = new PoolingDataSource();

	ds.setClassName(org.hsqldb.jdbc.pool.JDBCXADataSource.class.getName());
	ds.setUniqueName("batchdb");
	ds.setMaxPoolSize(100);

	Properties props = new Properties();
	props.setProperty("databaseName", "spring-batch-metadata");
	// props.setProperty("createDatabase", "create");
	ds.setDriverProperties(props);

	ds.setAllowLocalTransactions(true);

	final ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
	populator.addScript(batchDropSchemaScript);
	populator.addScript(batchCreateSchemaScript);
	DatabasePopulatorUtils.execute(populator, ds);

	return ds;
}
 
开发者ID:debop,项目名称:spring-batch-experiments,代码行数:23,代码来源:JtaConfiguration.java

示例7: applicationDataSource

import bitronix.tm.resource.jdbc.PoolingDataSource; //导入依赖的package包/类
@Bean(initMethod = "init", destroyMethod = "close")
public PoolingDataSource applicationDataSource() {
	PoolingDataSource ds = new PoolingDataSource();

	ds.setClassName(org.hsqldb.jdbc.pool.JDBCXADataSource.class.getName());
	ds.setUniqueName("appdb");
	ds.setMaxPoolSize(100);

	final Properties props = new Properties();
	props.setProperty("databaseName", "chapter09-application");
	// props.setProperty("createDatabase", "create");
	ds.setDriverProperties(props);

	ds.setAllowLocalTransactions(true);

	final ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
	populator.addScript(dropTablesScript);
	populator.addScript(createTableScript);
	DatabasePopulatorUtils.execute(populator, ds);

	return ds;
}
 
开发者ID:debop,项目名称:spring-batch-experiments,代码行数:23,代码来源:JtaConfiguration.java

示例8: setUp

import bitronix.tm.resource.jdbc.PoolingDataSource; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    TransactionManagerServices.getConfiguration().setJournal("null").setGracefulShutdownInterval(2);
    TransactionManagerServices.getTransactionManager();

    MockitoXADataSource.setStaticCloseXAConnectionException(null);
    MockitoXADataSource.setStaticGetXAConnectionException(null);

    pds = new PoolingDataSource();
    pds.setMinPoolSize(1);
    pds.setMaxPoolSize(2);
    pds.setMaxIdleTime(1);
    pds.setClassName(MockitoXADataSource.class.getName());
    pds.setUniqueName("pds");
    pds.setAllowLocalTransactions(true);
    pds.setAcquisitionTimeout(1);
    pds.init();
}
 
开发者ID:bitronix,项目名称:btm,代码行数:19,代码来源:JdbcPoolTest.java

示例9: testDefaultUserTransactionAndResources

import bitronix.tm.resource.jdbc.PoolingDataSource; //导入依赖的package包/类
public void testDefaultUserTransactionAndResources() throws Exception {
    PoolingDataSource pds = new PoolingDataSource();
    pds.setMaxPoolSize(1);
    pds.setClassName(MockitoXADataSource.class.getName());
    pds.setUniqueName("jdbc/pds");
    pds.init();

    Hashtable<String, String> env = new Hashtable<String, String>();
    env.put(Context.INITIAL_CONTEXT_FACTORY, BitronixInitialContextFactory.class.getName());
    Context ctx = new InitialContext(env);

    assertTrue(transactionManager == ctx.lookup("java:comp/UserTransaction"));

    try {
        ctx.lookup("aaa");
        fail("expected NameNotFoundException");
    } catch (NameNotFoundException ex) {
        assertEquals("unable to find a bound object at name 'aaa'", ex.getMessage());
    }

    assertTrue(pds == ctx.lookup("jdbc/pds"));

    ctx.close();

    pds.close();
}
 
开发者ID:bitronix,项目名称:btm,代码行数:27,代码来源:JndiTest.java

示例10: testFormatErrors

import bitronix.tm.resource.jdbc.PoolingDataSource; //导入依赖的package包/类
public void testFormatErrors() throws Exception {
    ResourceLoader loader = new ResourceLoader();

    Properties p = new Properties();
    p.setProperty("resource.ds2.className", MockitoXADataSource.class.getName());
    p.setProperty("resource.ds2.uniqueName", "some.more.unique.Name");
    p.setProperty("resource.ds2.maxPoolSize", "abc"); // incorrect format

    try {
        loader.initXAResourceProducers(p);
        fail("expected ResourceConfigurationException");
    } catch (ResourceConfigurationException ex) {
        assertEquals("cannot configure resource for configuration entries with name [ds2] - failing property is [maxPoolSize]", ex.getMessage());
    }

    p.setProperty("resource.ds2.className", MockitoXADataSource.class.getName());
    p.setProperty("resource.ds2.uniqueName", "some.also.other.unique.Name");
    p.setProperty("resource.ds2.maxPoolSize", "123");
    p.setProperty("resource.ds2.useTmJoin", "unknown"); // incorrect format, will default to false
    loader.initXAResourceProducers(p);


    PoolingDataSource pds = (PoolingDataSource) loader.getResources().get("some.also.other.unique.Name");
    assertFalse(pds.getUseTmJoin());
}
 
开发者ID:bitronix,项目名称:btm,代码行数:26,代码来源:ResourceLoaderTest.java

示例11: testAcquiringConnectionAfterRecoveryDoesNotMarkAsFailed

import bitronix.tm.resource.jdbc.PoolingDataSource; //导入依赖的package包/类
public void testAcquiringConnectionAfterRecoveryDoesNotMarkAsFailed() throws Exception {
    PoolingDataSource poolingDataSource = new PoolingDataSource();
    poolingDataSource.setClassName(MockitoXADataSource.class.getName());
    poolingDataSource.setUniqueName("ds1");
    poolingDataSource.setMaxPoolSize(1);
    poolingDataSource.setMaxIdleTime(1); // set low shrink timeout
    poolingDataSource.init();

    IncrementalRecoverer.recover(poolingDataSource);

    MockitoXADataSource.setStaticGetXAConnectionException(new SQLException("creating a new connection does not work"));
    Thread.sleep(2000); // wait for shrink

    // should not work but should not mark the pool as failed as it could recover
    try {
        poolingDataSource.getConnection();
        fail("expected SQLException");
    } catch (SQLException ex) {
        assertEquals("unable to get a connection from pool of a PoolingDataSource containing an XAPool of resource ds1 with 0 connection(s) (0 still available)", ex.getMessage());
    }

    poolingDataSource.close();
}
 
开发者ID:bitronix,项目名称:btm,代码行数:24,代码来源:JdbcFailedPoolTest.java

示例12: testFailingRecoveryMarksAsFailed

import bitronix.tm.resource.jdbc.PoolingDataSource; //导入依赖的package包/类
public void testFailingRecoveryMarksAsFailed() throws Exception {
    MockitoXADataSource.setStaticGetXAConnectionException(new SQLException("creating a new connection does not work"));

    PoolingDataSource poolingDataSource = new PoolingDataSource();
    poolingDataSource.setClassName(MockitoXADataSource.class.getName());
    poolingDataSource.setUniqueName("ds1");
    poolingDataSource.setMaxPoolSize(1);
    poolingDataSource.init();

    Recoverer recoverer = new Recoverer();
    recoverer.run();
    assertEquals("a PoolingDataSource containing an XAPool of resource ds1 with 0 connection(s) (0 still available) -failed-", poolingDataSource.toString());
    // recoverer must not unregister the resource
    assertSame(poolingDataSource, ResourceRegistrar.get("ds1"));

    MockitoXADataSource.setStaticGetXAConnectionException(null);

    recoverer.run();
    assertEquals("a PoolingDataSource containing an XAPool of resource ds1 with 1 connection(s) (1 still available)", poolingDataSource.toString());
    // recoverer must not unregister the resource
    assertSame(poolingDataSource, ResourceRegistrar.get("ds1"));

    poolingDataSource.close();
}
 
开发者ID:bitronix,项目名称:btm,代码行数:25,代码来源:JdbcFailedPoolTest.java

示例13: testRestartWithoutLoaderNoReuseResource

import bitronix.tm.resource.jdbc.PoolingDataSource; //导入依赖的package包/类
public void testRestartWithoutLoaderNoReuseResource() throws Exception {
    for (int i=0; i<3 ;i++) {
        PoolingDataSource pds = new PoolingDataSource();
        pds.setClassName(MockitoXADataSource.class.getName());
        pds.setUniqueName("ds");
        pds.setMaxPoolSize(1);
        pds.init();

        try {
            ResourceRegistrar.register(pds);
            fail("expected IllegalStateException");
        } catch (IllegalStateException ex) {
            String expected = "A resource with uniqueName 'ds' has already been registered";
            assertEquals(expected, ex.getMessage().substring(0, expected.length()));
        }

        BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager();
        tm.shutdown();
        assertEquals(1, ResourceRegistrar.getResourcesUniqueNames().size());

        pds.close();
    }
}
 
开发者ID:bitronix,项目名称:btm,代码行数:24,代码来源:RestartTest.java

示例14: testRestartWithoutLoaderReuseResource

import bitronix.tm.resource.jdbc.PoolingDataSource; //导入依赖的package包/类
public void testRestartWithoutLoaderReuseResource() throws Exception {
    PoolingDataSource pds = new PoolingDataSource();
    pds.setClassName(MockitoXADataSource.class.getName());
    pds.setUniqueName("ds");
    pds.setMaxPoolSize(1);
    pds.init();

    for (int i=0; i<3 ;i++) {
        try {
            ResourceRegistrar.register(pds);
            fail("expected IllegalStateException");
        } catch (IllegalStateException ex) {
            String expected = "A resource with uniqueName 'ds' has already been registered";
            assertEquals(expected, ex.getMessage().substring(0, expected.length()));
        }

        BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager();
        tm.shutdown();
        assertEquals(1, ResourceRegistrar.getResourcesUniqueNames().size());
    }

    pds.close();
}
 
开发者ID:bitronix,项目名称:btm,代码行数:24,代码来源:RestartTest.java

示例15: datasource

import bitronix.tm.resource.jdbc.PoolingDataSource; //导入依赖的package包/类
@Bean
public DataSource datasource() throws Exception {
    PoolingDataSource dataSource = new PoolingDataSource();
    dataSource.setClassName("bitronix.tm.resource.jdbc.lrc.LrcXADataSource");
    dataSource.setUniqueName("hsqldb");
    dataSource.setMaxPoolSize(5);
    dataSource.setAllowLocalTransactions(true);
    dataSource.getDriverProperties().setProperty("driverClassName", "org.hsqldb.jdbcDriver");
    dataSource.getDriverProperties().setProperty("url", "jdbc:hsqldb:mem:test");
    dataSource.getDriverProperties().setProperty("user", "sa");
    dataSource.getDriverProperties().setProperty("password", "theSaPassword");
    return dataSource;
}
 
开发者ID:Kloudtek,项目名称:ktspring,代码行数:14,代码来源:BitronixHsqlMemDbDatasourceConfig.java


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