本文整理汇总了Java中bitronix.tm.resource.jdbc.PoolingDataSource.setAllowLocalTransactions方法的典型用法代码示例。如果您正苦于以下问题:Java PoolingDataSource.setAllowLocalTransactions方法的具体用法?Java PoolingDataSource.setAllowLocalTransactions怎么用?Java PoolingDataSource.setAllowLocalTransactions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bitronix.tm.resource.jdbc.PoolingDataSource
的用法示例。
在下文中一共展示了PoolingDataSource.setAllowLocalTransactions方法的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);
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: 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();
}
示例6: 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;
}
示例7: 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
示例8: 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
示例9: 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
示例10: 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;
}
示例11: 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();
}
示例12: setupDataSource
import bitronix.tm.resource.jdbc.PoolingDataSource; //导入方法依赖的package包/类
public static PoolingDataSource setupDataSource() {
PoolingDataSource pds = new PoolingDataSource();
pds.setUniqueName("jdbc/jbpm-ds");
pds.setClassName("bitronix.tm.resource.jdbc.lrc.LrcXADataSource");
pds.setMaxPoolSize(5);
pds.setAllowLocalTransactions(true);
pds.getDriverProperties().put("user", DB_USER);
pds.getDriverProperties().put("password", DB_PASSWD);
pds.getDriverProperties().put("url", DB_URL);
pds.getDriverProperties().put("driverClassName", DB_DRIVER);
pds.init();
return pds;
}
示例13: testPoolNotStartingTransactionManager
import bitronix.tm.resource.jdbc.PoolingDataSource; //导入方法依赖的package包/类
public void testPoolNotStartingTransactionManager() throws Exception {
if (log.isDebugEnabled()) { log.debug("*** Starting testPoolNotStartingTransactionManager"); }
// make sure TM is not running
TransactionManagerServices.getTransactionManager().shutdown();
PoolingDataSource pds = new PoolingDataSource();
pds.setMinPoolSize(1);
pds.setMaxPoolSize(2);
pds.setMaxIdleTime(1);
pds.setClassName(MockitoXADataSource.class.getName());
pds.setUniqueName("pds2");
pds.setAllowLocalTransactions(true);
pds.setAcquisitionTimeout(1);
pds.init();
assertFalse(TransactionManagerServices.isTransactionManagerRunning());
Connection c = pds.getConnection();
Statement stmt = c.createStatement();
stmt.close();
c.close();
assertFalse(TransactionManagerServices.isTransactionManagerRunning());
pds.close();
assertFalse(TransactionManagerServices.isTransactionManagerRunning());
}
示例14: testRegisterTwoLrc
import bitronix.tm.resource.jdbc.PoolingDataSource; //导入方法依赖的package包/类
public void testRegisterTwoLrc() throws Exception {
BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager();
PoolingDataSource lrcDs1 = new PoolingDataSource();
lrcDs1.setClassName(LrcXADataSource.class.getName());
lrcDs1.setUniqueName(DATASOURCE1_NAME + "_lrc");
lrcDs1.setMinPoolSize(POOL_SIZE);
lrcDs1.setMaxPoolSize(POOL_SIZE);
lrcDs1.setAllowLocalTransactions(true);
lrcDs1.getDriverProperties().setProperty("driverClassName", MockDriver.class.getName());
lrcDs1.getDriverProperties().setProperty("url", "");
lrcDs1.init();
PoolingDataSource lrcDs2 = new PoolingDataSource();
lrcDs2.setClassName(LrcXADataSource.class.getName());
lrcDs2.setUniqueName(DATASOURCE2_NAME + "_lrc");
lrcDs2.setMinPoolSize(POOL_SIZE);
lrcDs2.setMaxPoolSize(POOL_SIZE);
lrcDs2.setAllowLocalTransactions(true);
lrcDs2.getDriverProperties().setProperty("driverClassName", MockDriver.class.getName());
lrcDs2.getDriverProperties().setProperty("url", "");
lrcDs2.init();
tm.begin();
Connection c1 = lrcDs1.getConnection();
c1.createStatement();
c1.close();
Connection c2 = lrcDs2.getConnection();
try {
c2.createStatement();
fail("expected SQLException");
} catch (SQLException ex) {
assertTrue(ex.getMessage().startsWith("error enlisting a ConnectionJavaProxy of a JdbcPooledConnection from datasource pds2_lrc in state ACCESSIBLE with usage count 1 wrapping a JDBC LrcXAConnection on a JDBC LrcConnectionJavaProxy on Mock"));
assertTrue(ex.getCause().getMessage().matches("cannot enlist more than one non-XA resource, tried enlisting an XAResourceHolderState with uniqueName=pds2_lrc XAResource=a JDBC LrcXAResource in state NO_TX with XID null, already enlisted: an XAResourceHolderState with uniqueName=pds1_lrc XAResource=a JDBC LrcXAResource in state STARTED \\(started\\) with XID a Bitronix XID .*"));
}
c2.close();
tm.commit();
lrcDs2.close();
lrcDs1.close();
}
示例15: testRegisterTwoLrcJms
import bitronix.tm.resource.jdbc.PoolingDataSource; //导入方法依赖的package包/类
public void testRegisterTwoLrcJms() throws Exception {
BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager();
PoolingConnectionFactory pcf = new PoolingConnectionFactory();
pcf.setClassName(LrcXAConnectionFactory.class.getName());
pcf.setUniqueName("pcf_lrc");
pcf.setMaxPoolSize(1);
pcf.getDriverProperties().setProperty("connectionFactoryClassName", MockConnectionFactory.class.getName());
pcf.init();
PoolingDataSource lrcDs2 = new PoolingDataSource();
lrcDs2.setClassName(LrcXADataSource.class.getName());
lrcDs2.setUniqueName(DATASOURCE2_NAME + "_lrc");
lrcDs2.setMinPoolSize(POOL_SIZE);
lrcDs2.setMaxPoolSize(POOL_SIZE);
lrcDs2.setAllowLocalTransactions(true);
lrcDs2.getDriverProperties().setProperty("driverClassName", MockDriver.class.getName());
lrcDs2.getDriverProperties().setProperty("url", "");
lrcDs2.init();
tm.begin();
javax.jms.Connection c = pcf.createConnection();
javax.jms.Session s = c.createSession(true, 0);
javax.jms.MessageProducer p = s.createProducer(null);
p.send(null);
c.close();
Connection c2 = lrcDs2.getConnection();
try {
c2.createStatement();
fail("expected SQLException");
} catch (SQLException ex) {
assertTrue(ex.getMessage().startsWith("error enlisting a ConnectionJavaProxy of a JdbcPooledConnection from datasource pds2_lrc in state ACCESSIBLE with usage count 1 wrapping a JDBC LrcXAConnection on a JDBC LrcConnectionJavaProxy on Mock"));
assertTrue(ex.getCause().getMessage().startsWith("cannot enlist more than one non-XA resource, tried enlisting an XAResourceHolderState with uniqueName=pds2_lrc XAResource=a JDBC LrcXAResource in state NO_TX with XID null, already enlisted: an XAResourceHolderState with uniqueName=pcf_lrc XAResource=a JMS LrcXAResource in state STARTED of session Mock for Session"));
}
c2.close();
tm.commit();
lrcDs2.close();
pcf.close();
}