Bug #22729 XA RECOVER returns no result
Submitted: 27 Sep 2006 8:56 Modified: 10 Oct 2006 14:53
Reporter: Yuan WANG Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:5.0.3 OS:Linux (linux)
Assigned to: CPU Architecture:Any
Tags: xa

[27 Sep 2006 8:56] Yuan WANG
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());
	}

}
[27 Sep 2006 9:02] Yuan WANG
Sorry for the false positive, I read the change logs later on and found this is an API change and not a bug.