code: public boolean isQueryRelaunchable(Method method, Object[] args) {
      if (method != null) {
        switch (method.getName()) {
          case "executeQuery":
            if (!((Boolean) args[0])) {
              return true; //launched on slave connection
            }
            if (args[2] instanceof String) {
              return ((String) args[2]).toUpperCase(Locale.ROOT).startsWith("SELECT");
            } else if (args[2] instanceof ClientPrepareResult) {
              @SuppressWarnings("unchecked")
              String query = new String(((ClientPrepareResult) args[2]).getQueryParts().get(0))
                  .toUpperCase(Locale.ROOT);
              return query.startsWith("SELECT");
            }
            break;
          case "executePreparedQuery":
            if (!((Boolean) args[0])) {
              return true; //launched on slave connection
            }
            ServerPrepareResult serverPrepareResult = (ServerPrepareResult) args[1];
            return (serverPrepareResult.getSql()).toUpperCase(Locale.ROOT).startsWith("SELECT");
          case "executeBatchStmt":
          case "executeBatchClient":
          case "executeBatchServer":
            return !((Boolean) args[0]);
          default:
            return false;
        }
      }
      return false;
    }
docs: Check if query can be re-executed.
  
  @param method invoke method
  @param args   invoke arguments
  @return true if can be re-executed