• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java MySQLDMLUpdateParser类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中com.alibaba.cobar.parser.recognizer.mysql.syntax.MySQLDMLUpdateParser的典型用法代码示例。如果您正苦于以下问题:Java MySQLDMLUpdateParser类的具体用法?Java MySQLDMLUpdateParser怎么用?Java MySQLDMLUpdateParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

MySQLDMLUpdateParser类属于com.alibaba.cobar.parser.recognizer.mysql.syntax包,在下文中一共展示了MySQLDMLUpdateParser类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: parse

点赞 2

import com.alibaba.cobar.parser.recognizer.mysql.syntax.MySQLDMLUpdateParser; //导入依赖的package包/类
public static SQLStatement parse(String sql, MySQLLexer lexer, String charset) throws SQLSyntaxErrorException {
    try {
        SQLStatement stmt = null;
        boolean isEOF = true;
        MySQLExprParser exprParser = new MySQLExprParser(lexer, charset);
        stmtSwitch: switch (lexer.token()) {
            case KW_DESC:
            case KW_DESCRIBE:
                stmt = new MySQLDALParser(lexer, exprParser).desc();
                break stmtSwitch;
            case KW_SELECT:
            case PUNC_LEFT_PAREN:
                stmt = new MySQLDMLSelectParser(lexer, exprParser).selectUnion();
                break stmtSwitch;
            case KW_DELETE:
                stmt = new MySQLDMLDeleteParser(lexer, exprParser).delete();
                break stmtSwitch;
            case KW_INSERT:
                stmt = new MySQLDMLInsertParser(lexer, exprParser).insert();
                break stmtSwitch;
            case KW_REPLACE:
                stmt = new MySQLDMLReplaceParser(lexer, exprParser).replace();
                break stmtSwitch;
            case KW_UPDATE:
                stmt = new MySQLDMLUpdateParser(lexer, exprParser).update();
                break stmtSwitch;
            case KW_CALL:
                stmt = new MySQLDMLCallParser(lexer, exprParser).call();
                break stmtSwitch;
            case KW_SET:
                stmt = new MySQLDALParser(lexer, exprParser).set();
                break stmtSwitch;
            case KW_SHOW:
                stmt = new MySQLDALParser(lexer, exprParser).show();
                break stmtSwitch;
            case KW_ALTER:
            case KW_CREATE:
            case KW_DROP:
            case KW_RENAME:
                stmt = new MySQLDDLParser(lexer, exprParser).ddlStmt();
                isEOF = isEOFedDDL(stmt);
                break stmtSwitch;
            case KW_RELEASE:
                stmt = new MySQLMTSParser(lexer).release();
                break stmtSwitch;
            case IDENTIFIER:
                SpecialIdentifier si = null;
                if ((si = specialIdentifiers.get(lexer.stringValueUppercase())) != null) {
                    switch (si) {
                        case TRUNCATE:
                            stmt = new MySQLDDLParser(lexer, exprParser).truncate();
                            break stmtSwitch;
                        case SAVEPOINT:
                            stmt = new MySQLMTSParser(lexer).savepoint();
                            break stmtSwitch;
                        case ROLLBACK:
                            stmt = new MySQLMTSParser(lexer).rollback();
                            break stmtSwitch;
                    }
                }
            default:
                throw new SQLSyntaxErrorException("sql is not a supported statement");
        }
        if (isEOF) {
            while (lexer.token() == MySQLToken.PUNC_SEMICOLON) {
                lexer.nextToken();
            }
            if (lexer.token() != MySQLToken.EOF) {
                throw new SQLSyntaxErrorException("SQL syntax error!");
            }
        }
        return stmt;
    } catch (Exception e) {
        throw new SQLSyntaxErrorException(buildErrorMsg(e, lexer, sql), e);
    }
}
 

开发者ID:beebeandwer,
项目名称:TDDL,
代码行数:77,
代码来源:SQLParserDelegate.java

示例2: parse

点赞 2

import com.alibaba.cobar.parser.recognizer.mysql.syntax.MySQLDMLUpdateParser; //导入依赖的package包/类
public static SQLStatement parse(String sql, MySQLLexer lexer, String charset) throws SQLSyntaxErrorException {
    try {
        SQLStatement stmt = null;
        boolean isEOF = true;
        MySQLExprParser exprParser = new MySQLExprParser(lexer, charset);
        stmtSwitch: switch (lexer.token()) {
        case KW_DESC:
        case KW_DESCRIBE:
            stmt = new MySQLDALParser(lexer, exprParser).desc();
            break stmtSwitch;
        case KW_SELECT:
        case PUNC_LEFT_PAREN:
            stmt = new MySQLDMLSelectParser(lexer, exprParser).selectUnion();
            break stmtSwitch;
        case KW_DELETE:
            stmt = new MySQLDMLDeleteParser(lexer, exprParser).delete();
            break stmtSwitch;
        case KW_INSERT:
            stmt = new MySQLDMLInsertParser(lexer, exprParser).insert();
            break stmtSwitch;
        case KW_REPLACE:
            stmt = new MySQLDMLReplaceParser(lexer, exprParser).replace();
            break stmtSwitch;
        case KW_UPDATE:
            stmt = new MySQLDMLUpdateParser(lexer, exprParser).update();
            break stmtSwitch;
        case KW_CALL:
            stmt = new MySQLDMLCallParser(lexer, exprParser).call();
            break stmtSwitch;
        case KW_SET:
            stmt = new MySQLDALParser(lexer, exprParser).set();
            break stmtSwitch;
        case KW_SHOW:
            stmt = new MySQLDALParser(lexer, exprParser).show();
            break stmtSwitch;
        case KW_ALTER:
        case KW_CREATE:
        case KW_DROP:
        case KW_RENAME:
            stmt = new MySQLDDLParser(lexer, exprParser).ddlStmt();
            isEOF = isEOFedDDL(stmt);
            break stmtSwitch;
        case KW_RELEASE:
            stmt = new MySQLMTSParser(lexer).release();
            break stmtSwitch;
        case IDENTIFIER:
            SpecialIdentifier si = null;
            if ((si = specialIdentifiers.get(lexer.stringValueUppercase())) != null) {
                switch (si) {
                case TRUNCATE:
                    stmt = new MySQLDDLParser(lexer, exprParser).truncate();
                    break stmtSwitch;
                case SAVEPOINT:
                    stmt = new MySQLMTSParser(lexer).savepoint();
                    break stmtSwitch;
                case ROLLBACK:
                    stmt = new MySQLMTSParser(lexer).rollback();
                    break stmtSwitch;
                }
            }
        default:
            throw new SQLSyntaxErrorException("sql is not a supported statement");
        }
        if (isEOF) {
            while (lexer.token() == MySQLToken.PUNC_SEMICOLON) {
                lexer.nextToken();
            }
            if (lexer.token() != MySQLToken.EOF) {
                throw new SQLSyntaxErrorException("SQL syntax error!");
            }
        }
        return stmt;
    } catch (Exception e) {
        throw new SQLSyntaxErrorException(buildErrorMsg(e, lexer, sql), e);
    }
}
 

开发者ID:alibaba,
项目名称:cobar,
代码行数:77,
代码来源:SQLParserDelegate.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)