code: public static ResultSet explode(Connection connection, String tableName) throws SQLException {
          String regex = ".*(?i)\\b(select|from)\\b.*";
          Pattern pattern = Pattern.compile(regex);
          Matcher matcher = pattern.matcher(tableName);
          if (matcher.find()) {
              if (tableName.startsWith("(") && tableName.endsWith(")")) {
                  ExplodeResultSetQuery explodeResultSetQuery = new ExplodeResultSetQuery(connection, tableName, null);
                  return explodeResultSetQuery.getResultSet();
              } else {
                  throw new SQLException("The select query must be enclosed in parenthesis: '(SELECT * FROM ORDERS)'.");
              }
          }
          return explode(connection, tableName, null);
      }
docs: Explode Geometry Collection into multiple geometries
  @param connection
  @param tableName the name of the input table or select query
  @return A result set with the same content of specified table but with atomic geometries and duplicate values.
  @throws java.sql.SQLException