Java Code Examples for com.alibaba.fastsql.sql.SQLUtils#parseStatements()

The following examples show how to use com.alibaba.fastsql.sql.SQLUtils#parseStatements() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MycatDBSharedServerImpl.java    From Mycat2 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Iterator<RowBaseIterator> executeSqls(String sql, MycatDBContext dbContext) {
    List<SQLStatement> statements = SQLUtils.parseStatements(sql, DbType.mysql);
    List<MycatSQLPrepareObject> collect = new ArrayList<>();
    for (SQLStatement statement : statements) {
        MycatSQLPrepareObject query = prepare(sql, null, statement, dbContext);
        collect.add(query);
    }
    Iterator<MycatSQLPrepareObject> iterator = collect.iterator();
    return new Iterator<RowBaseIterator>() {
        @Override
        public boolean hasNext() {
            return iterator.hasNext();
        }

        @Override
        public RowBaseIterator next() {
            return iterator.next().plan(Collections.emptyList()).run();
        }
    };
}
 
Example 2
Source File: SQL2ResultSetUtil.java    From Mycat2 with GNU General Public License v3.0 4 votes vote down vote up
public static MycatRowMetaDataImpl getMycatRowMetaData(String createTableStmtText) {
    List<SQLStatement> statements = SQLUtils.parseStatements(createTableStmtText, DbType.mysql);
    MySqlCreateTableStatement mySqlCreateTableStatement = (MySqlCreateTableStatement) statements.get(statements.size() - 1);
    String tableName = mySqlCreateTableStatement.getTableSource().computeAlias();
    return new MycatRowMetaDataImpl(mySqlCreateTableStatement.getColumnDefinitions(), "", tableName);
}