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


Java PoolingDataSource.setUniqueName方法代码示例

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


在下文中一共展示了PoolingDataSource.setUniqueName方法的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: actualDataSource

import bitronix.tm.resource.jdbc.PoolingDataSource; //导入方法依赖的package包/类
@Bean(destroyMethod = "close")
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;
}
 
开发者ID:vladmihalcea,项目名称:high-performance-java-persistence,代码行数:15,代码来源:JTATransactionManagerConfiguration.java

示例12: actualDataSource

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

示例13: actualDataSource

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

示例14: dataSource

import bitronix.tm.resource.jdbc.PoolingDataSource; //导入方法依赖的package包/类
@Bean
	public javax.sql.DataSource dataSource() {
		// TODO: make it as configurable
		PoolingDataSource dataSource0 = new PoolingDataSource();
		dataSource0.setClassName("com.mysql.jdbc.jdbc2.optional.MysqlXADataSource");
		try {
			//Each datasource must be assigned a unique name. This is required for distributed crash recovery.
			dataSource0.setUniqueName(InetAddress.getLocalHost().getHostAddress());
		} catch (UnknownHostException e) {
		}
		dataSource0.setAutomaticEnlistingEnabled(true);
		dataSource0.setAllowLocalTransactions(true);
		dataSource0.setShareTransactionConnections(true);
		dataSource0.setUseTmJoin(true);
		dataSource0.setMinPoolSize(1);
		dataSource0.setMaxPoolSize(100);
		
		Properties driverProperties = new Properties();
		driverProperties.put("url", this.getDataSource().getUrl());
		driverProperties.put("user", this.getDataSource().getUsername());
		driverProperties.put("password", this.getDataSource().getPassword());
		driverProperties.put("password", this.getDataSource().getPassword());
//		driverProperties.put("journal", this.getDataSource().getPassword());
//		driverProperties.put("log-part1-filename", "btm1.tlog");
//		driverProperties.put("log-part2-filename", "btm2.tlog");
		
		dataSource0.setDriverProperties(driverProperties);
		dataSource0.init();
		return dataSource0;
	}
 
开发者ID:shaolinwu,项目名称:uimaster,代码行数:31,代码来源:PersistentConfig.java

示例15: setupPoolingDataSource

import bitronix.tm.resource.jdbc.PoolingDataSource; //导入方法依赖的package包/类
/**
 * Configure a datasource for our engine use. It is configured for MySQL
 */
private static void setupPoolingDataSource() {
	PoolingDataSource pds = new PoolingDataSource();
	pds.setMaxPoolSize(10);
	pds.setMinPoolSize(10);
	pds.setUniqueName(DS_NAME);
	pds.setClassName("com.mysql.jdbc.jdbc2.optional.MysqlXADataSource");
	pds.setAllowLocalTransactions(true);
	pds.getDriverProperties().put("user", USER);
	pds.getDriverProperties().put("password", PASSWORD);
	pds.getDriverProperties().put("url", URL);
	pds.getDriverProperties().put("databaseName", DB_NAME);
	pds.init();
}
 
开发者ID:jesuino,项目名称:bpms6-examples,代码行数:17,代码来源:Util.java


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