Skip to content

Commit b6af418

Browse files
authored
feature: support shentongdatabase xa mode (#7664)
1 parent e06d364 commit b6af418

38 files changed

+477
-248
lines changed

.github/workflows/test-druid.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ jobs:
4242
fail-fast: false
4343
matrix:
4444
druid: [
45+
1.2.25,
46+
# 1.2.24, #The source code depends on guava, resulting in a class not found, see the commit https://github.com/alibaba/druid/commit/f060c2701587948380bd0d07d5baf4f774c06e8a#diff-5200f514252efbc0c4b2dc51ebad5d840b4b3065b9556eb4368bd3476d4c220eR25
47+
1.2.23,
48+
1.2.22,
49+
1.2.21,
4550
1.2.20,
4651
1.2.19,
4752
#1.2.18, # Unit test triggered a bug in Druid, see the commit https://github.com/alibaba/druid/commit/6c493f852852fb287ed5fd31ee16c27ead0ea5cf

changes/en-us/2.x.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Add changes here for all PR submitted to the 2.x branch.
2626
- [[#7551](https://github.com/apache/incubator-seata/pull/7551)] XAUtils add support for DM Database
2727
- [[#7559](https://github.com/apache/incubator-seata/pull/7559)] Introduce Cleanup API for TableMetaRefreshHolder Instance
2828
- [[#7669](https://github.com/apache/incubator-seata/pull/7669)] add support for Jackson serialization and deserialization of PostgreSQL array types
29+
- [[#7664](https://github.com/apache/incubator-seata/pull/7664)] support shentongdatabase XA mode
2930

3031
### bugfix:
3132

@@ -107,5 +108,6 @@ Thanks to these contributors for their code commits. Please report an unintended
107108
- [YoWuwuuuw](https://github.com/YoWuwuuuw)
108109
- [jihun4452](https://github.com/jihun4452)
109110
- [psxjoy](https://github.com/psxjoy)
111+
- [dsomehan](https://github.com/dsomehan)
110112

111113
Also, we receive many valuable issues, questions and advices from our community. Thanks for you all.

changes/zh-cn/2.x.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
- [[#7551](https://github.com/apache/incubator-seata/pull/7551)] XAUtils支持达梦数据库
2727
- [[#7559](https://github.com/apache/incubator-seata/pull/7559)] 为 TableMetaRefreshHolder 实例引入清理 API
2828
- [[#7669](https://github.com/apache/incubator-seata/pull/7669)] 添加对 Jackson 序列化和反序列化 PostgreSQL 数组类型的支持
29+
- [[#7664](https://github.com/apache/incubator-seata/pull/7565)] 支持神通数据库的XA模式
2930

3031

3132
### bugfix:
@@ -109,5 +110,7 @@
109110
- [YoWuwuuuw](https://github.com/YoWuwuuuw)
110111
- [jihun4452](https://github.com/jihun4452)
111112
- [psxjoy](https://github.com/psxjoy)
113+
- [dsomehan](https://github.com/dsomehan)
114+
112115

113116
同时,我们收到了社区反馈的很多有价值的issue和建议,非常感谢大家。

compatible/src/test/java/io/seata/rm/datasource/xa/DataSourceProxyXATest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package io.seata.rm.datasource.xa;
1818

1919
import com.alibaba.druid.pool.DruidDataSource;
20+
import com.alibaba.druid.pool.DruidStatementConnection;
2021
import com.mysql.jdbc.JDBC4MySQLConnection;
2122
import com.mysql.jdbc.jdbc2.optional.JDBC4ConnectionWrapper;
2223
import io.seata.core.context.RootContext;
@@ -66,6 +67,7 @@ public void testGetConnection() throws SQLException {
6667

6768
DruidDataSource druidDataSource = new DruidDataSource();
6869
druidDataSource.setDriver(driver);
70+
druidDataSource.setUrl("jdbc:mysql:xxx");
6971
DataSourceProxyXA dataSourceProxyXA = new DataSourceProxyXA(druidDataSource);
7072
RootContext.unbind();
7173
Connection connFromDataSourceProxyXA = dataSourceProxyXA.getConnection();
@@ -79,6 +81,9 @@ public void testGetConnection() throws SQLException {
7981
Assertions.assertTrue(wrappedConnection instanceof PooledConnection);
8082

8183
Connection wrappedPhysicalConn = ((PooledConnection) wrappedConnection).getConnection();
84+
if (wrappedPhysicalConn instanceof DruidStatementConnection) {
85+
wrappedPhysicalConn = ((DruidStatementConnection) wrappedPhysicalConn).getConnection();
86+
}
8287
Assertions.assertSame(wrappedPhysicalConn, connection);
8388

8489
XAConnection xaConnection = connectionProxyXA.getWrappedXAConnection();
@@ -101,6 +106,7 @@ public void testGetMariaXaConnection() throws SQLException, ClassNotFoundExcepti
101106

102107
DruidDataSource druidDataSource = new DruidDataSource();
103108
druidDataSource.setDriver(driver);
109+
druidDataSource.setUrl("jdbc:mariadb:xxx");
104110
DataSourceProxyXA dataSourceProxyXA = new DataSourceProxyXA(druidDataSource);
105111
RootContext.unbind();
106112
Connection connFromDataSourceProxyXA = dataSourceProxyXA.getConnection();
@@ -115,6 +121,9 @@ public void testGetMariaXaConnection() throws SQLException, ClassNotFoundExcepti
115121
Assertions.assertTrue(wrappedConnection instanceof PooledConnection);
116122

117123
Connection wrappedPhysicalConn = ((PooledConnection) wrappedConnection).getConnection();
124+
if (wrappedPhysicalConn instanceof DruidStatementConnection) {
125+
wrappedPhysicalConn = ((DruidStatementConnection) wrappedPhysicalConn).getConnection();
126+
}
118127
Assertions.assertSame(wrappedPhysicalConn, connection);
119128

120129
XAConnection xaConnection = connectionProxyXA.getWrappedXAConnection();

dependencies/pom.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,9 @@
114114
<h2.version>1.4.181</h2.version>
115115
<mariadb.version>2.7.2</mariadb.version>
116116
<kingbase.version>9.0.0</kingbase.version>
117+
<oscar.version>4.1.152</oscar.version>
117118
<!-- db connection pool -->
118-
<druid.version>1.2.20</druid.version>
119+
<druid.version>1.2.25</druid.version>
119120
<commons-dbcp2.version>2.9.0</commons-dbcp2.version>
120121
<hikari.version>3.4.3</hikari.version>
121122
<caffeine.version>2.9.3</caffeine.version>
@@ -924,6 +925,11 @@
924925
<artifactId>kingbase8</artifactId>
925926
<version>${kingbase.version}</version>
926927
</dependency>
928+
<dependency>
929+
<groupId>com.shentongdata</groupId>
930+
<artifactId>oscarJDBC8</artifactId>
931+
<version>${oscar.version}</version>
932+
</dependency>
927933
</dependencies>
928934
</dependencyManagement>
929935
</project>

distribution/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ Apache-2.0 licenses
221221
com.alibaba.nacos:nacos-api 1.4.6 Apache-2.0
222222
com.alibaba.nacos:nacos-client 1.4.6 Apache-2.0
223223
com.alibaba.nacos:nacos-common 1.4.6 Apache-2.0
224-
com.alibaba:druid 1.2.20 Apache-2.0
224+
com.alibaba:druid 1.2.25 Apache-2.0
225225
com.alibaba:fastjson 1.2.83 Apache-2.0
226226
com.alibaba.fastjson2:fastjson2 2.0.52 Apache-2.0
227227
com.alipay.sofa.common:sofa-common-tools 1.0.12 Apache-2.0

distribution/LICENSE-server

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ Apache-2.0 licenses
243243
org.apache.curator:curator-test 5.1.0 Apache-2.0
244244
com.lmax:disruptor 3.3.7 Apache-2.0
245245
com.dameng:DmJdbcDriver18 8.1.2.192 Apache-2.0
246-
com.alibaba:druid 1.2.20 Apache-2.0
246+
com.alibaba:druid 1.2.25 Apache-2.0
247247
com.google.errorprone:error_prone_annotations 2.21.1 Apache-2.0
248248
com.netflix.eureka:eureka-client 1.10.18 Apache-2.0
249249
net.jodah:failsafe 2.3.3 Apache-2.0

distribution/NOTICE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ Please copy database driver dependencies, such as `mysql-connector-java.jar`, to
562562
│   ├── curator-test-5.1.0.jar
563563
│   ├── dexx-collections-0.2.jar
564564
│   ├── disruptor-3.3.7.jar
565-
│   ├── druid-1.2.20.jar
565+
│   ├── druid-1.2.25.jar
566566
│   ├── error_prone_annotations-2.21.1.jar
567567
│   ├── eureka-client-1.10.18.jar
568568
│   ├── failsafe-2.3.3.jar
@@ -1719,7 +1719,7 @@ Please copy database driver dependencies, such as `mysql-connector-java.jar`, to
17191719
│   ├── curator-test-5.1.0.jar
17201720
│   ├── dexx-collections-0.2.jar
17211721
│   ├── disruptor-3.3.7.jar
1722-
│   ├── druid-1.2.20.jar
1722+
│   ├── druid-1.2.25.jar
17231723
│   ├── error_prone_annotations-2.21.1.jar
17241724
│   ├── eureka-client-1.10.18.jar
17251725
│   ├── failsafe-2.3.3.jar

rm-datasource/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,5 +154,10 @@
154154
<artifactId>kingbase8</artifactId>
155155
<scope>test</scope>
156156
</dependency>
157+
<dependency>
158+
<groupId>com.shentongdata</groupId>
159+
<artifactId>oscarJDBC8</artifactId>
160+
<scope>test</scope>
161+
</dependency>
157162
</dependencies>
158163
</project>

rm-datasource/src/main/java/org/apache/seata/rm/datasource/util/XAUtils.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ public static XAConnection createXAConnection(Connection physicalConn, Driver dr
7070
return PGUtils.createXAConnection(physicalConn);
7171
case JdbcConstants.KINGBASE:
7272
return createXAConnection(physicalConn, "com.kingbase8.xa.KBXAConnection", dbType);
73+
case JdbcConstants.OSCAR:
74+
return createXAConnection(physicalConn, "com.oscar.xa.Jdbc3XAConnection", dbType);
7375
case JdbcConstants.DM:
7476
return createXAConnection(physicalConn, "dm.jdbc.driver.DmdbXAConnection", dbType);
7577
default:
@@ -118,6 +120,8 @@ private static Constructor<XAConnection> getConstructorByDBType(Class xaConnecti
118120
return xaConnectionClass.getConstructor(kingbaseConnectionClass);
119121
case JdbcConstants.DM:
120122
return xaConnectionClass.getConstructor(Connection.class);
123+
case JdbcConstants.OSCAR:
124+
return xaConnectionClass.getConstructor(Connection.class);
121125
default:
122126
throw new SQLException("xa reflect not support dbType: " + dbType);
123127
}
@@ -143,6 +147,9 @@ private static <T> List<T> getInitargsByDBType(String dbType, Object... params)
143147
case JdbcConstants.KINGBASE:
144148
result.add(params[0]);
145149
return result;
150+
case JdbcConstants.OSCAR:
151+
result.add(params[0]);
152+
return result;
146153
case JdbcConstants.MARIADB:
147154
Class mariaDbConnectionClass = Class.forName("org.mariadb.jdbc.MariaDbConnection");
148155
if (mariaDbConnectionClass.isInstance(params[0])) {

0 commit comments

Comments
 (0)