Description:
XAResource.recover() always returns empty.
How to repeat:
Open a mysql client, construct a pending XA transaction as the followings.
xa start 'a','b';
insert into t values(1);
xa end 'a','b';
xa prepare 'a','b';
Then check pending XA transactions via JDBC, no results with be found. Here is a simple test program:
import java.sql.SQLException;
import javax.sql.XAConnection;
import javax.transaction.xa.XAException;
import javax.transaction.xa.XAResource;
import javax.transaction.xa.Xid;
import com.mysql.jdbc.jdbc2.optional.MysqlXADataSource;
public class TestJDBCXaRecover {
public static void main(String[] args) throws ClassNotFoundException, SQLException, XAException {
Class.forName("com.mysql.jdbc.Driver");
MysqlXADataSource xaDS = new MysqlXADataSource();
xaDS.setUrl("jdbc:mysql://localhost/test");
xaDS.setUser("root");
xaDS.setPassword(null);
XAConnection xaConn = xaDS.getXAConnection();
XAResource xaRes = xaConn.getXAResource();
Xid[] suspendXids = xaRes.recover(XAResource.TMNOFLAGS);
for(int i=0;i<suspendXids.length;i++)
System.out.println(suspendXids[i].toString());
}
}