当前位置: 首页>>代码示例>>Java>>正文


Java SQLStatementParser.parseStatementList方法代码示例

本文整理汇总了Java中com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList方法的典型用法代码示例。如果您正苦于以下问题:Java SQLStatementParser.parseStatementList方法的具体用法?Java SQLStatementParser.parseStatementList怎么用?Java SQLStatementParser.parseStatementList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.alibaba.druid.sql.parser.SQLStatementParser的用法示例。


在下文中一共展示了SQLStatementParser.parseStatementList方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parserSQL

import com.alibaba.druid.sql.parser.SQLStatementParser; //导入方法依赖的package包/类
@Override
public SQLStatement parserSQL(String originSql) throws SQLSyntaxErrorException {
    SQLStatementParser parser = new MySqlStatementParser(originSql);

    /**
     * thrown SQL SyntaxError if parser error
     */
    try {
        List<SQLStatement> list = parser.parseStatementList();
        if (list.size() > 1) {
            throw new SQLSyntaxErrorException("MultiQueries is not supported,use single query instead ");
        }
        return list.get(0);
    } catch (Exception t) {
        LOGGER.info("routeNormalSqlWithAST", t);
        if (t.getMessage() != null) {
            throw new SQLSyntaxErrorException(t.getMessage());
        } else {
            throw new SQLSyntaxErrorException(t);
        }
    }
}
 
开发者ID:actiontech,项目名称:dble,代码行数:23,代码来源:DefaultRouteStrategy.java

示例2: getCountSql

import com.alibaba.druid.sql.parser.SQLStatementParser; //导入方法依赖的package包/类
@Override
public String getCountSql(String sql) {
	SQLStatementParser parser = new MySqlStatementParser(sql);
	List<SQLStatement> stmtList = parser.parseStatementList();

	// 将AST通过visitor输出
	StringBuilder out = new StringBuilder();
	MysqlCountOutputVisitor visitor = new MysqlCountOutputVisitor(out);

	for (SQLStatement stmt : stmtList) {
		if (stmt instanceof SQLSelectStatement) {
			stmt.accept(visitor);
			out.append(";");
		}
	}

	return out.toString();
}
 
开发者ID:dianping,项目名称:zebra,代码行数:19,代码来源:MySQLDialect.java

示例3: oracleValidationQueryCheck

import com.alibaba.druid.sql.parser.SQLStatementParser; //导入方法依赖的package包/类
private void oracleValidationQueryCheck() {
    if (validationQuery == null) {
        return;
    }
    if (validationQuery.length() == 0) {
        return;
    }

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

    if (stmtList.size() != 1) {
        return;
    }

    SQLStatement stmt = stmtList.get(0);
    if (!(stmt instanceof SQLSelectStatement)) {
        return;
    }

    SQLSelectQuery query = ((SQLSelectStatement) stmt).getSelect().getQuery();
    if (query instanceof SQLSelectQueryBlock) {
        if (((SQLSelectQueryBlock) query).getFrom() == null) {
            LOG.error("invalid oracle validationQuery. " + validationQuery + ", may should be : " + validationQuery
                    + " FROM DUAL");
        }
    }
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:29,代码来源:ElasticSearchDruidDataSource.java

示例4: db2ValidationQueryCheck

import com.alibaba.druid.sql.parser.SQLStatementParser; //导入方法依赖的package包/类
private void db2ValidationQueryCheck() {
    if (validationQuery == null) {
        return;
    }
    if (validationQuery.length() == 0) {
        return;
    }

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

    if (stmtList.size() != 1) {
        return;
    }

    SQLStatement stmt = stmtList.get(0);
    if (!(stmt instanceof SQLSelectStatement)) {
        return;
    }

    SQLSelectQuery query = ((SQLSelectStatement) stmt).getSelect().getQuery();
    if (query instanceof SQLSelectQueryBlock) {
        if (((SQLSelectQueryBlock) query).getFrom() == null) {
            LOG.error("invalid db2 validationQuery. " + validationQuery + ", may should be : " + validationQuery
                    + " FROM SYSDUMMY");
        }
    }
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:29,代码来源:ElasticSearchDruidDataSource.java

示例5: parseSql

import com.alibaba.druid.sql.parser.SQLStatementParser; //导入方法依赖的package包/类
private static SQLStatement parseSql(String sql) {
    String convertSql = trimPattern.matcher(sql).replaceAll("xtrim");
    SQLStatementParser parser = new OracleStatementParser(convertSql);
    List<SQLStatement> stmtList;
    try {
        stmtList = parser.parseStatementList();
    } catch (ParserException exception) {
        exception.printStackTrace();
        throw new RuntimeException(sql + " is invalid, detail " + exception.getMessage());
    }

    return stmtList.get(0);
}
 
开发者ID:bingoohuang,项目名称:javacode-demo,代码行数:14,代码来源:OracleSensitiveFieldsParser.java

示例6: sqlValid

import com.alibaba.druid.sql.parser.SQLStatementParser; //导入方法依赖的package包/类
public static void sqlValid(String sql, DataBaseType dataBaseType){
    SQLStatementParser statementParser = SQLParserUtils.createSQLStatementParser(sql,dataBaseType.getTypeName());
    statementParser.parseStatementList();
}
 
开发者ID:yaogdu,项目名称:datax,代码行数:5,代码来源:DBUtil.java

示例7: testTrimxResult

import com.alibaba.druid.sql.parser.SQLStatementParser; //导入方法依赖的package包/类
@Test
public void testTrimxResult() {
    SQLStatementParser parser = new OracleStatementParser(trimxSql);
    parser.parseStatementList();
}
 
开发者ID:bingoohuang,项目名称:javacode-demo,代码行数:6,代码来源:OracleSensitiveFieldsParserTest.java

示例8: testTrimResultBug

import com.alibaba.druid.sql.parser.SQLStatementParser; //导入方法依赖的package包/类
@Test//(expected = ParserException.class)
// ParserException: syntax error, expect FROM, actual RPAREN CERT_CHECK_RSP_CODE
public void testTrimResultBug() {
    SQLStatementParser parser = new OracleStatementParser(trimSql);
    parser.parseStatementList();
}
 
开发者ID:bingoohuang,项目名称:javacode-demo,代码行数:7,代码来源:OracleSensitiveFieldsParserTest.java


注:本文中的com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。