code: public static QueryRootNode createQuery(String statement, LocationFactory resolver, QueryNodeFactory factory)
        throws InvalidQueryException
     {
        try
        {
           // get parser
           JCRSQLParser parser;
           synchronized (parsers)
           {
              parser = parsers.get(resolver);
              if (parser == null)
              {
                 parser = new JCRSQLParser(new StringReader(statement));
                 //parser.setNameResolver(resolver);
                 parser.setLocationfactory(resolver);
                 parsers.put(resolver, parser);
              }
           }
  
           JCRSQLQueryBuilder builder;
           // guard against concurrent use within same session
           synchronized (parser)
           {
              parser.ReInit(new StringReader(statement));
              builder = new JCRSQLQueryBuilder(parser.Query(), resolver, factory);
           }
           return builder.getRootNode();
        }
        catch (ParseException e)
        {
           throw new InvalidQueryException(e.getMessage());
        }
        catch (IllegalArgumentException e)
        {
           throw new InvalidQueryException(e.getMessage());
        }
        catch (Throwable t) //NOSONAR
        {
           log.error(t.getLocalizedMessage(), t);
           // javacc parser may also throw an error in some cases
           throw new InvalidQueryException(t.getMessage(), t);
        }
     }
docs: Creates a <code>QueryNode</code> tree from a SQL <code>statement</code>
  using the passed query node <code>factory</code>.
  
  @param statement the SQL statement.
  @param resolver  the namespace resolver to use.
  @return the <code>QueryNode</code> tree.
  @throws InvalidQueryException if <code>statement</code> is malformed.