Package com.alibaba.druid.sql.parser

Examples of com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList()


    LOG.debug("Parsing SQL " + context.getSql());
    SQLStatementParser parser = WaspSqlParserUtils.createSQLStatementParser(
        context.getSql(), WaspSqlParserUtils.WASP); // JdbcUtils.MYSQL
                                                    // JdbcUtils.HBASE
    // WaspSqlParserUtils.WASP
    List<SQLStatement> stmtList = parser.parseStatementList();
    if (stmtList == null) {
      throw new UnsupportedException("Non SQLStatement");
    }
    if (stmtList.size() > 1) {
      throw new UnsupportedException("Multi SQLStatement Unsupported"
View Full Code Here



    String sql5 = "insert into test (datetime) value (now())";
    SQLStatementParser parser = WaspSqlParserUtils.createSQLStatementParser(
        sql4, WaspSqlParserUtils.WASP);
    List<SQLStatement> stmtList = parser.parseStatementList();
    String sql6 = "";


    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:MM:SS");
    Calendar calendar = Calendar.getInstance();
View Full Code Here

public class MySqlMockExecuteHandlerImpl implements MockExecuteHandler {

    @Override
    public ResultSet executeQuery(MockStatement statement, String sql) throws SQLException {
        SQLStatementParser parser = new MySqlStatementParser(sql);
        List<SQLStatement> stmtList = parser.parseStatementList(); //

        if (stmtList.size() > 1) {
            throw new SQLException("not support multi-statment. " + sql);
        }
View Full Code Here

            if (!config.isCommentAllow()) {
                parser.getLexer().setAllowComment(false); // deny comment
            }

            parser.parseStatementList(statementList);

            final Token lastToken = parser.getLexer().token();
            if (lastToken != Token.EOF) {
                violations.add(new IllegalSQLObjectViolation(ErrorCode.SYNTAX_ERROR, "not terminal sql, token "
                                                                                     + lastToken, sql));
View Full Code Here

        if (validationQuery.length() == 0) {
            return;
        }

        SQLStatementParser sqlStmtParser = SQLParserUtils.createSQLStatementParser(validationQuery, this.dbType);
        List<SQLStatement> stmtList = sqlStmtParser.parseStatementList();

        if (stmtList.size() != 1) {
            return;
        }
View Full Code Here

        if (validationQuery.length() == 0) {
            return;
        }

        SQLStatementParser sqlStmtParser = SQLParserUtils.createSQLStatementParser(validationQuery, this.dbType);
        List<SQLStatement> stmtList = sqlStmtParser.parseStatementList();

        if (stmtList.size() != 1) {
            return;
        }
View Full Code Here

    public static final String ATTR_PARAMS_SKIP = "druid.parameterized.skip";

    public static String parameterize(String sql, String dbType) {
        SQLStatementParser parser = SQLParserUtils.createSQLStatementParser(sql, dbType);
        List<SQLStatement> statementList = parser.parseStatementList();
        if (statementList.size() == 0) {
            return sql;
        }

        SQLStatement stmt = statementList.get(0);
View Full Code Here

    public static final String ATTR_PARAMS_SKIP = "druid.parameterized.skip";

    public static String parameterize(String sql, String dbType) {
        SQLStatementParser parser = SQLParserUtils.createSQLStatementParser(sql, dbType);
        List<SQLStatement> statementList = parser.parseStatementList();
        if (statementList.size() == 0) {
            return sql;
        }

        StringBuilder out = new StringBuilder();
View Full Code Here

        }
       
        if(!isWhite) {
            if (text.startsWith("SET")) {
                SQLStatementParser parser = new MySqlStatementParser(text);
                List<SQLStatement> statementList = parser.parseStatementList();
                if (statementList != null && statementList.size() > 0)  {
                    SQLStatement statement = statementList.get(0);
                    if (statement instanceof SQLSetStatement || statement instanceof MySqlSetCharSetStatement
                        || statement instanceof MySqlSetNamesStatement) {
                        isWhite = true;
View Full Code Here

        if (validationQuery.length() == 0) {
            return;
        }

        SQLStatementParser sqlStmtParser = SQLParserUtils.createSQLStatementParser(validationQuery, this.dbType);
        List<SQLStatement> stmtList = sqlStmtParser.parseStatementList();

        if (stmtList.size() != 1) {
            return;
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.