code: public Xid[] recover(int flags) throws XAException {
      // Return all Xid  at once, when STARTRSCAN is specified
      // Return zero-length array otherwise.
  
      if (((flags & TMSTARTRSCAN) == 0) && ((flags & TMENDRSCAN) == 0) && (flags != TMNOFLAGS)) {
        throw new XAException(XAException.XAER_INVAL);
      }
  
      if ((flags & TMSTARTRSCAN) == 0) {
        return new MariaDbXid[0];
      }
  
      try {
        ResultSet rs = connection.createStatement().executeQuery("XA RECOVER");
        ArrayList<MariaDbXid> xidList = new ArrayList<>();
  
        while (rs.next()) {
          int formatId = rs.getInt(1);
          int len1 = rs.getInt(2);
          int len2 = rs.getInt(3);
          byte[] arr = rs.getBytes(4);
  
          byte[] globalTransactionId = new byte[len1];
          byte[] branchQualifier = new byte[len2];
          System.arraycopy(arr, 0, globalTransactionId, 0, len1);
          System.arraycopy(arr, len1, branchQualifier, 0, len2);
          xidList.add(new MariaDbXid(formatId, globalTransactionId, branchQualifier));
        }
        Xid[] xids = new Xid[xidList.size()];
        xidList.toArray(xids);
        return xids;
      } catch (SQLException sqle) {
        throw mapXaException(sqle);
      }
    }
docs: Obtains a list of prepared transaction branches from a resource manager. The transaction
  manager calls this method during recovery to obtain the list of transaction branches that are
  currently in prepared or heuristically completed states.
  
  @param flags One of TMSTARTRSCAN, TMENDRSCAN, TMNOFLAGS. TMNOFLAGS must be used when no other
  flags are set in the parameter.
  @return The resource manager returns zero or more XIDs of the transaction branches.
  @throws XAException An error has occurred. Possible values are XAER_RMERR, XAER_RMFAIL,
  XAER_INVAL, and XAER_PROTO.