【 使用环境 】测试环境
【 OB or 其他组件 】OB 商业版
【 使用版本 】驱动版本 oceanbase-client-2.4.12.jar
【问题描述】尝试使用 oceanbase JDBC 驱动开启 XA 事务报语法错误。
【复现路径】
public static void testXaCommit() throws Exception {
Connection conn = getConnection(url1);
Connection conn2 = getConnection(url2);
XAResource xaResource = new OceanBaseXaConnection((OceanBaseConnection) conn).getXAResource();
XAResource xaResource2 = new OceanBaseXaConnection((OceanBaseConnection) conn2).getXAResource();
Xid xid1 = new OceanBaseXid(formatId, globalTransactionId, branch1);
Xid xid2 = new OceanBaseXid(formatId, globalTransactionId, branch2);
xaResource.start(xid1, XAResource.TMNOFLAGS);
xaResource2.start(xid2, XAResource.TMNOFLAGS);
xaResource.end(xid1, XAResource.TMSUCCESS);
xaResource.prepare(xid1);
xaResource2.end(xid2, XAResource.TMSUCCESS);
xaResource2.prepare(xid2);
System.out.println("prepared");
Xid[] result = xaResource.recover(XAResource.TMSTARTRSCAN);
for (Xid each : result) {
System.out.println("xid1: " + each);
}
System.out.println("before commit");
xaResource.commit(xid1, false);
xaResource2.commit(xid2, false);
System.out.println("commit success");
conn.close();
conn2.close();
}
public static String cname = "com.alipay.oceanbase.jdbc.Driver";
public static Connection getConnection(String url) throws ClassNotFoundException, SQLException {
Class.forName(cname);
return DriverManager.getConnection(url, userName, password);
}
报错信息如下:
使用官方文档上的 demo 测试也报错,报错如下:
https://www.oceanbase.com/docs/common-oceanbase-connector-j-cn-10000000001130709