PreparedStatement ps = connection.prepareStatement(RECOVER);
try {
ps.setString(0, systemId);
ResultSet rs = ps.executeQuery();
try {
Xid lastXid = null;
Xid currentXid = null;
Recovery.XidBranchesPair xidBranchesPair = null;
while (rs.next()) {
int formatId = rs.getInt(0);
byte[] globalId = rs.getBytes(1);
byte[] globalBranchId = rs.getBytes(2);
byte[] branchBranchId = rs.getBytes(3);
String name = rs.getString(4);
currentXid = xidFactory.recover(formatId, globalId, globalBranchId);
Xid branchXid = xidFactory.recover(formatId, globalId, branchBranchId);
if (!currentXid.equals(lastXid)) {
xidBranchesPair = new Recovery.XidBranchesPair(currentXid, null);
recovered.add(xidBranchesPair);
lastXid = currentXid;
}