use of com.alibaba.druid.pool.xa.DruidXADataSource in project seata by seata.
the class XAModeTest2 method createNewDruidXADataSource.
private DruidXADataSource createNewDruidXADataSource() throws Throwable {
DruidXADataSource druidDataSource = new DruidXADataSource();
initDruidDataSource(druidDataSource);
return druidDataSource;
}
use of com.alibaba.druid.pool.xa.DruidXADataSource in project Mycat2 by MyCATApache.
the class SeataXADatasourceProvider method createDataSource.
@Override
public JdbcDataSource createDataSource(DatasourceConfig config) {
String username = config.getUser();
String password = config.getPassword();
String url = Objects.requireNonNull(config.getUrl());
String dbType = config.getDbType();
int maxRetryCount = config.getMaxRetryCount();
List<String> initSQLs = config.getInitSqls();
int maxCon = config.getMaxCon();
int minCon = config.getMinCon();
DruidXADataSource datasource = new DruidXADataSource();
datasource.setPassword(password);
datasource.setUsername(username);
datasource.setUrl(url);
datasource.setMaxWait(TimeUnit.SECONDS.toMillis(60));
datasource.setMaxActive(maxCon);
datasource.setMinIdle(minCon);
datasource.setKeepAlive(true);
datasource.setTestOnReturn(true);
datasource.setTestOnBorrow(true);
datasource.setValidationQuery("select 'x'");
datasource.setTestWhileIdle(true);
if (maxRetryCount > 0) {
datasource.setConnectionErrorRetryAttempts(maxRetryCount);
}
if (dbType != null) {
datasource.setDbType(dbType);
}
if (initSQLs != null) {
datasource.setConnectionInitSqls(initSQLs);
}
return new JdbcDataSource(config, new DataSourceProxyXA(datasource));
}
use of com.alibaba.druid.pool.xa.DruidXADataSource in project mybatis.flying by limeng32.
the class DataSourceConfig method xaDataSource2.
public XADataSource xaDataSource2() {
DruidXADataSource xaDataSource = new DruidXADataSource();
xaDataSource.setUrl("jdbc:h2:mem:testdb2;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;
}
use of com.alibaba.druid.pool.xa.DruidXADataSource in project druid by alibaba.
the class H2XATest method setUp.
protected void setUp() throws Exception {
super.setUp();
dataSource = new DruidXADataSource();
dataSource.setMinIdle(1);
dataSource.setUrl("jdbc:h2:mem:test;");
dataSource.setTestOnBorrow(false);
JdbcUtils.execute(dataSource, "CREATE TABLE user (id INT, name VARCHAR(40))");
}
use of com.alibaba.druid.pool.xa.DruidXADataSource in project citrus by Yiuman.
the class DynamicDataSourceAutoConfiguration method buildDruidXaDataSource.
/**
* 根据配置构建XA数据源
*
* @param resourceName 资源名,用于定义XA唯一资源
* @param properties 数据源配置
* @return XA数据源
*/
public DataSource buildDruidXaDataSource(String resourceName, DataSourceProperties properties) {
DruidXADataSource druidDataSource = new DruidXADataSource();
druidDataSource.setUrl(properties.getUrl());
druidDataSource.setUsername(properties.getUsername());
druidDataSource.setPassword(properties.getPassword());
druidDataSource.setDriverClassName(properties.getDriverClassName());
AtomikosDataSourceBean atomikosDataSourceBean = new AtomikosDataSourceBean();
atomikosDataSourceBean.setXaDataSource(druidDataSource);
atomikosDataSourceBean.setUniqueResourceName(String.format("%s$$%s", resourceName, UUID.randomUUID().toString().substring(0, 15)));
return atomikosDataSourceBean;
}
Aggregations