core/src/main/java/com/orientechnologies/orient/core/sql/parser/OStatementCache.java
protected static OStatement parse(String statement) throws OCommandSQLParsingException {
    try {
      ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined();
      InputStream is;

      if (db == null) {
        is = new ByteArrayInputStream(statement.getBytes());
      } else {
        try {
          is = new ByteArrayInputStream(statement.getBytes(db.getStorage().getConfiguration().getCharset()));
        } catch (UnsupportedEncodingException e2) {
          OLogManager.instance()
              .warn(null, "Unsupported charset for database " + db + " " + db.getStorage().getConfiguration().getCharset());
          is = new ByteArrayInputStream(statement.getBytes());
        }
      }

      OrientSql osql = null;
      if (db == null) {
        osql = new OrientSql(is);
      } else {
        try {
          osql = new OrientSql(is, db.getStorage().getConfiguration().getCharset());
        } catch (UnsupportedEncodingException e2) {
          OLogManager.instance()
              .warn(null, "Unsupported charset for database " + db + " " + db.getStorage().getConfiguration().getCharset());
          osql = new OrientSql(is);
        }
      }
      OStatement result = osql.parse();
      result.originalStatement = statement;

      return result;
    } catch (ParseException e) {
      throwParsingException(e, statement);
    } catch (TokenMgrError e2) {
      throwParsingException(e2, statement);
    }
    return null;
  }
protected static OStatement parse(String statement) throws OCommandSQLParsingException {
    try {
      ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined();
      InputStream is;

      if (db == null) {
        is = new ByteArrayInputStream(statement.getBytes());
      } else {
        try {
          is = new ByteArrayInputStream(statement.getBytes(db.getStorage().getConfiguration().getCharset()));
        } catch (UnsupportedEncodingException e2) {
          OLogManager.instance()
              .warn(null, "Unsupported charset for database " + db + " " + db.getStorage().getConfiguration().getCharset());
          is = new ByteArrayInputStream(statement.getBytes());
        }
      }

      OrientSql osql = null;
      if (db == null) {
        osql = new OrientSql(is);
      } else {
        try {
          osql = new OrientSql(is, db.getStorage().getConfiguration().getCharset());
        } catch (UnsupportedEncodingException e2) {
          OLogManager.instance()
              .warn(null, "Unsupported charset for database " + db + " " + db.getStorage().getConfiguration().getCharset());
          osql = new OrientSql(is);
        }
      }
      OStatement result = osql.parse();
      result.originalStatement = statement;

      return result;
    } catch (ParseException e) {
      throwParsingException(e, statement);
    } catch (TokenMgrError e2) {
      throwParsingException(e2, statement);
    }
    return null;
  }
protected static OStatement parse ( String statement ) throws OCommandSQLParsingException { try { ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal . instance ( ) . getIfDefined ( ) ; InputStream is ; if ( db == null ) { is = new ByteArrayInputStream ( statement . getBytes ( ) ) ; } else { try { is = new ByteArrayInputStream ( statement . getBytes ( db . getStorage ( ) . getConfiguration ( ) . getCharset ( ) ) ) ; } catch ( UnsupportedEncodingException e2 ) { OLogManager . instance ( ) . warn ( null , "Unsupported charset for database " + db + " " + db . getStorage ( ) . getConfiguration ( ) . getCharset ( ) ) ; is = new ByteArrayInputStream ( statement . getBytes ( ) ) ; } } OrientSql osql = null ; if ( db == null ) { osql = new OrientSql ( is ) ; } else { try { osql = new OrientSql ( is , db . getStorage ( ) . getConfiguration ( ) . getCharset ( ) ) ; } catch ( UnsupportedEncodingException e2 ) { OLogManager . instance ( ) . warn ( null , "Unsupported charset for database " + db + " " + db . getStorage ( ) . getConfiguration ( ) . getCharset ( ) ) ; osql = new OrientSql ( is ) ; } } OStatement result = osql . parse ( ) ; result . originalStatement = statement ; return result ; } catch ( ParseException e ) { throwParsingException ( e , statement ) ; } catch ( TokenMgrError e2 ) { throwParsingException ( e2 , statement ) ; } return null ; }
parses an SQL statement and returns the corresponding executor

@param statement the SQL statement

@return the corresponding executor

@throws OCommandSQLParsingException if the input parameter is not a valid SQL statement
parses an SQL statement and returns the corresponding executor