Search in sources :

Example 1 with DruidXADataSource

use of com.alibaba.druid.pool.xa.DruidXADataSource in project warn-report by saaavsaaa.

the class DistributeTransaction method initXADataSource.

DruidXADataSource[] initXADataSource() {
    System.out.print("Create a XADataSource_1 data source: ");
    DruidXADataSource xaDataSource_1 = new DruidXADataSource();
    xaDataSource_1.setDbType(props.getProperty("db1.dbtype"));
    xaDataSource_1.setUrl(props.getProperty("db1.url"));
    xaDataSource_1.setUsername(props.getProperty("db1.username"));
    xaDataSource_1.setPassword(props.getProperty("db1.password"));
    System.out.println("Okay.");
    System.out.print("Create a XADataSource_2 data source: ");
    DruidXADataSource xaDataSource_2 = new DruidXADataSource();
    xaDataSource_2.setDbType(props.getProperty("db2.dbtype"));
    xaDataSource_2.setUrl(props.getProperty("db2.url"));
    xaDataSource_2.setUsername(props.getProperty("db2.username"));
    xaDataSource_2.setPassword(props.getProperty("db2.password"));
    System.out.println("Okay.");
    return new DruidXADataSource[] { xaDataSource_1, xaDataSource_2 };
}
Also used : DruidXADataSource(com.alibaba.druid.pool.xa.DruidXADataSource)

Example 2 with DruidXADataSource

use of com.alibaba.druid.pool.xa.DruidXADataSource in project warn-report by saaavsaaa.

the class DistributeTransaction method initXADataSource.

DruidXADataSource[] initXADataSource() {
    System.out.print("Create a XADataSource_1 data source: ");
    DruidXADataSource xaDataSource_1 = new DruidXADataSource();
    xaDataSource_1.setDbType(props.getProperty("db1.dbtype"));
    xaDataSource_1.setUrl(props.getProperty("db1.url"));
    xaDataSource_1.setUsername(props.getProperty("db1.username"));
    xaDataSource_1.setPassword(props.getProperty("db1.password"));
    System.out.println("Okay.");
    System.out.print("Create a XADataSource_2 data source: ");
    DruidXADataSource xaDataSource_2 = new DruidXADataSource();
    xaDataSource_2.setDbType(props.getProperty("db2.dbtype"));
    xaDataSource_2.setUrl(props.getProperty("db2.url"));
    xaDataSource_2.setUsername(props.getProperty("db2.username"));
    xaDataSource_2.setPassword(props.getProperty("db2.password"));
    System.out.println("Okay.");
    return new DruidXADataSource[] { xaDataSource_1, xaDataSource_2 };
}
Also used : DruidXADataSource(com.alibaba.druid.pool.xa.DruidXADataSource)

Example 3 with DruidXADataSource

use of com.alibaba.druid.pool.xa.DruidXADataSource in project mybatis.flying by limeng32.

the class DataSourceConfig method xaDataSource1.

public XADataSource xaDataSource1() {
    DruidXADataSource xaDataSource = new DruidXADataSource();
    xaDataSource.setUrl("jdbc:h2:mem:testdb;MODE=MySQL;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;MV_STORE=FALSE;MVCC=FALSE;FILE_LOCK=NO");
    xaDataSource.setUsername("sa1");
    xaDataSource.setPassword("null");
    return xaDataSource;
}
Also used : DruidXADataSource(com.alibaba.druid.pool.xa.DruidXADataSource)

Example 4 with DruidXADataSource

use of com.alibaba.druid.pool.xa.DruidXADataSource in project dynamic_dataSource by tianliuzhen.

the class MyBatisConfig1 method oneDataSource.

// 配置第一个数据源
@Primary
@Bean(name = "oneDataSource")
public DataSource oneDataSource() {
    // 这里datasource要使用阿里的支持XA的DruidXADataSource
    DruidXADataSource datasource = new DruidXADataSource();
    BeanUtils.copyProperties(oneDataSourceProperties, datasource);
    AtomikosDataSourceBean xaDataSource = new AtomikosDataSourceBean();
    xaDataSource.setXaDataSource(datasource);
    xaDataSource.setUniqueResourceName("oneDataSource");
    return xaDataSource;
}
Also used : AtomikosDataSourceBean(org.springframework.boot.jta.atomikos.AtomikosDataSourceBean) DruidXADataSource(com.alibaba.druid.pool.xa.DruidXADataSource) Primary(org.springframework.context.annotation.Primary) SqlSessionFactoryBean(org.mybatis.spring.SqlSessionFactoryBean) AtomikosDataSourceBean(org.springframework.boot.jta.atomikos.AtomikosDataSourceBean) Bean(org.springframework.context.annotation.Bean)

Example 5 with DruidXADataSource

use of com.alibaba.druid.pool.xa.DruidXADataSource in project dynamic_dataSource by tianliuzhen.

the class MyBatisConfig2 method twoDataSource.

@Bean(name = "twoDataSource")
public DataSource twoDataSource() {
    DruidXADataSource datasource = new DruidXADataSource();
    BeanUtils.copyProperties(twoDataSourceProperties, datasource);
    AtomikosDataSourceBean xaDataSource = new AtomikosDataSourceBean();
    xaDataSource.setXaDataSource(datasource);
    xaDataSource.setUniqueResourceName("twoDataSource");
    return xaDataSource;
}
Also used : AtomikosDataSourceBean(org.springframework.boot.jta.atomikos.AtomikosDataSourceBean) DruidXADataSource(com.alibaba.druid.pool.xa.DruidXADataSource) SqlSessionFactoryBean(org.mybatis.spring.SqlSessionFactoryBean) AtomikosDataSourceBean(org.springframework.boot.jta.atomikos.AtomikosDataSourceBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

DruidXADataSource (com.alibaba.druid.pool.xa.DruidXADataSource)11 AtomikosDataSourceBean (org.springframework.boot.jta.atomikos.AtomikosDataSourceBean)3 SqlSessionFactoryBean (org.mybatis.spring.SqlSessionFactoryBean)2 Bean (org.springframework.context.annotation.Bean)2 JdbcDataSource (io.mycat.datasource.jdbc.datasource.JdbcDataSource)1 DataSourceProxyXA (io.seata.rm.datasource.xa.DataSourceProxyXA)1 XAXid (io.seata.rm.datasource.xa.XAXid)1 XAConnection (javax.sql.XAConnection)1 XAResource (javax.transaction.xa.XAResource)1 Xid (javax.transaction.xa.Xid)1 Disabled (org.junit.jupiter.api.Disabled)1 Test (org.junit.jupiter.api.Test)1 Primary (org.springframework.context.annotation.Primary)1