Connection connection = dataSource.getConnection();
try {
PreparedStatement ps = connection.prepareStatement(INSERT_XID);
try {
for (Iterator iterator = branches.iterator(); iterator.hasNext();) {
TransactionBranchInfo branch = (TransactionBranchInfo) iterator.next();
ps.setString(0, systemId);
ps.setInt(1, formatId);
ps.setBytes(2, globalTransactionId);
ps.setBytes(3, branchQualifier);
ps.setBytes(4, branch.getBranchXid().getBranchQualifier());
ps.setString(5, branch.getResourceName());
ps.execute();
}
} finally {
ps.close();
}