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


Java SqlType类代码示例

本文整理汇总了Java中com.taobao.tddl.common.model.SqlType的典型用法代码示例。如果您正苦于以下问题:Java SqlType类的具体用法?Java SqlType怎么用?Java SqlType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SqlType类属于com.taobao.tddl.common.model包,在下文中一共展示了SqlType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: executeQuery

import com.taobao.tddl.common.model.SqlType; //导入依赖的package包/类
@Override
public ResultSet executeQuery(String sql) throws SQLException {
    checkClosed();
    ensureResultSetIsEmpty();

    boolean gotoRead = SqlType.SELECT.equals(SqlTypeParser.getSqlType(sql)) && tGroupConnection.getAutoCommit();
    Connection conn = tGroupConnection.getBaseConnection(sql, gotoRead);

    if (conn != null) {
        sql = GroupHintParser.removeTddlGroupHint(sql);
        return executeQueryOnConnection(conn, sql);
    } else {
        // hint优先
        GroupIndex dataSourceIndex = GroupHintParser.convertHint2Index(sql);
        sql = GroupHintParser.removeTddlGroupHint(sql);
        if (dataSourceIndex == null) {
            dataSourceIndex = ThreadLocalDataSourceIndex.getIndex();
        }
        return this.tGroupDataSource.getDBSelector(gotoRead).tryExecute(executeQueryTryer,
            retryingTimes,
            sql,
            dataSourceIndex);
    }
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:25,代码来源:TGroupStatement.java

示例2: executeQuery

import com.taobao.tddl.common.model.SqlType; //导入依赖的package包/类
@Override
public ResultSet executeQuery() throws SQLException {
    checkClosed();
    ensureResultSetIsEmpty();

    boolean gotoRead = SqlType.SELECT.equals(SqlTypeParser.getSqlType(sql)) && tGroupConnection.getAutoCommit();
    Connection conn = tGroupConnection.getBaseConnection(sql, gotoRead);

    if (conn != null) {
        sql = GroupHintParser.removeTddlGroupHint(sql);
        return executeQueryOnConnection(conn, sql);
    } else {
        // hint优先
        GroupIndex dataSourceIndex = GroupHintParser.convertHint2Index(sql);
        sql = GroupHintParser.removeTddlGroupHint(sql);
        if (dataSourceIndex == null) {
            dataSourceIndex = ThreadLocalDataSourceIndex.getIndex();
        }

        return tGroupDataSource.getDBSelector(gotoRead).tryExecute(executeQueryTryer,
            retryingTimes,
            sql,
            dataSourceIndex);
    }
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:26,代码来源:TGroupPreparedStatement.java

示例3: buildRulePlain

import com.taobao.tddl.common.model.SqlType; //导入依赖的package包/类
/**
 * 根据规则生成对应的执行计划
 */
private IDataNodeExecutor buildRulePlain(SqlType sqlType, List<TargetDB> targetDBs, Map<String, String> sqls) {
    List<IDataNodeExecutor> subs = new ArrayList<IDataNodeExecutor>();
    for (TargetDB target : targetDBs) {
        for (String table : target.getTableNames()) {
            subs.add(buildOneDirectPlan(sqlType, target.getDbIndex(), sqls.get(table)));
        }
    }

    if (subs.size() > 1) {
        IMerge merge = ASTNodeFactory.getInstance().createMerge();
        for (IDataNodeExecutor sub : subs) {
            merge.addSubNode(sub);
        }
        merge.executeOn(subs.get(0).getDataNode());// 选择第一个
        return merge;
    } else {
        return subs.get(0);
    }
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:23,代码来源:CostBasedOptimizer.java

示例4: execute

import com.taobao.tddl.common.model.SqlType; //导入依赖的package包/类
@Override
public boolean execute() throws SQLException {
    if (log.isDebugEnabled()) {
        log.debug("invoke execute, sql = " + sql);
    }

    SqlType sqlType = PreParser.getSqlType(sql);
    if (sqlType == SqlType.SELECT || sqlType == SqlType.SELECT_FOR_UPDATE
    /**
     * show 不支持吗 || sqlType == SqlType.SHOW
     **/
    ) {
        executeQuery();
        return true;
    } else if (sqlType == SqlType.INSERT || sqlType == SqlType.UPDATE || sqlType == SqlType.DELETE
               || sqlType == SqlType.REPLACE || sqlType == SqlType.TRUNCATE || sqlType == SqlType.CREATE
               || sqlType == SqlType.DROP || sqlType == SqlType.LOAD || sqlType == SqlType.MERGE) {
        super.updateCount = executeUpdate();
        return false;
    } else {
        throw new SQLException("only select, insert, update, delete,truncate,create,drop,load,merge sql is supported");
    }
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:24,代码来源:TPreparedStatement.java

示例5: executeQuery

import com.taobao.tddl.common.model.SqlType; //导入依赖的package包/类
public ResultSet executeQuery(String sql) throws SQLException {
    checkClosed();
    ensureResultSetIsEmpty();

    boolean gotoRead = SqlType.SELECT.equals(SqlTypeParser.getSqlType(sql)) && tGroupConnection.getAutoCommit();
    Connection conn = tGroupConnection.getBaseConnection(sql, gotoRead);

    if (conn != null) {
        sql = GroupHintParser.removeTddlGroupHint(sql);
        return executeQueryOnConnection(conn, sql);
    } else {
        // hint优先
        GroupIndex dataSourceIndex = GroupHintParser.convertHint2Index(sql);
        sql = GroupHintParser.removeTddlGroupHint(sql);
        if (dataSourceIndex == null) {
            dataSourceIndex = ThreadLocalDataSourceIndex.getIndex();
        }
        return this.tGroupDataSource.getDBSelector(gotoRead).tryExecute(executeQueryTryer,
            retryingTimes,
            sql,
            dataSourceIndex);
    }
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:24,代码来源:TGroupStatement.java

示例6: executeQuery

import com.taobao.tddl.common.model.SqlType; //导入依赖的package包/类
public ResultSet executeQuery() throws SQLException {
    checkClosed();
    ensureResultSetIsEmpty();

    boolean gotoRead = SqlType.SELECT.equals(SqlTypeParser.getSqlType(sql)) && tGroupConnection.getAutoCommit();
    Connection conn = tGroupConnection.getBaseConnection(sql, gotoRead);

    if (conn != null) {
        sql = GroupHintParser.removeTddlGroupHint(sql);
        return executeQueryOnConnection(conn, sql);
    } else {
        // hint优先
        GroupIndex dataSourceIndex = GroupHintParser.convertHint2Index(sql);
        sql = GroupHintParser.removeTddlGroupHint(sql);
        if (dataSourceIndex == null) {
            dataSourceIndex = ThreadLocalDataSourceIndex.getIndex();
        }

        return tGroupDataSource.getDBSelector(gotoRead).tryExecute(executeQueryTryer,
            retryingTimes,
            sql,
            dataSourceIndex);
    }
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:25,代码来源:TGroupPreparedStatement.java

示例7: isQuerySqlType

import com.taobao.tddl.common.model.SqlType; //导入依赖的package包/类
public static boolean isQuerySqlType(SqlType sqlType) {
    if (sqlType == SqlType.SELECT || sqlType == SqlType.SELECT_FOR_UPDATE || sqlType == SqlType.SHOW
        || sqlType == SqlType.DESC || sqlType == SqlType.DUMP || sqlType == SqlType.DEBUG
        || sqlType == SqlType.EXPLAIN || sqlType == SqlType.SELECT_LAST_INSERT_ID
        || sqlType == SqlType.SELECT_WITHOUT_TABLE || sqlType == SqlType.PROCEDURE) {
        return true;
    } else {
        return false;
    }
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:11,代码来源:SqlTypeParser.java

示例8: getAstNode

import com.taobao.tddl.common.model.SqlType; //导入依赖的package包/类
@Override
public ASTNode getAstNode() {
    if (sqlType == SqlType.SELECT || sqlType == SqlType.SELECT_LAST_INSERT_ID
        || sqlType == SqlType.SELECT_WITHOUT_TABLE) {
        return getQueryTreeNode();
    } else if (sqlType == SqlType.UPDATE) {
        return getUpdateNode();
    } else if (sqlType == SqlType.INSERT) {
        return getInsertNode();
    } else if (sqlType == SqlType.REPLACE) {
        return getReplaceNode();
    } else if (sqlType == SqlType.DELETE) {
        return getDeleteNode();
    } else if (sqlType == SqlType.CREATE_SEQUENCE) {
        visited();
        return ((SequenceVisitor) visitor).getCreateSequenceInsert();
    } else if (sqlType == SqlType.SHOW_SEQUENCES) {
        visited();
        return ((SequenceVisitor) visitor).getShowSequencesSelect();
    } else if (sqlType == SqlType.TDDL_SHOW) {
        visited();
        return ((MySqlShowVisitor) visitor).getNode();
    } else if (sqlType == SqlType.LOAD) {
        visited();
        ASTNode ast = ((MySqlLoadDataVisitor) visitor).getNode();
        ast.setSql(sql);
        return ast;
    } else if (sqlType == SqlType.GET_SEQUENCE) {
        return getSequence;
    } else if (sqlType == SqlType.RELOAD) {
        visited();
        return ((ReloadVisitor) visitor).getNode();
    }

    throw new NotSupportException(sqlType.toString());
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:37,代码来源:CobarSqlAnalysisResult.java

示例9: buildRulePlain

import com.taobao.tddl.common.model.SqlType; //导入依赖的package包/类
/**
 * 根据规则生成对应的执行计划
 */
private List<IDataNodeExecutor> buildRulePlain(SqlType sqlType, List<TargetDB> targetDBs, Map<String, String> sqls,
                                               int index) {
    List<IDataNodeExecutor> subs = new ArrayList<IDataNodeExecutor>();
    for (TargetDB target : targetDBs) {
        for (String table : target.getTableNames()) {
            subs.add(buildOneDirectPlan(sqlType, target.getDbIndex(), sqls.get(table), index));
        }
    }

    return subs;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:15,代码来源:CostBasedOptimizer.java

示例10: buildDirectPlan

import com.taobao.tddl.common.model.SqlType; //导入依赖的package包/类
/**
 * 根据指定的库和表生成执行计划
 */
private List<IDataNodeExecutor> buildDirectPlan(SqlType sqlType, String dbId, Map<String, String> sqls, int index) {
    List<IDataNodeExecutor> plans = new ArrayList<IDataNodeExecutor>();
    for (String sql : sqls.values()) {
        String[] dbIds = StringUtils.split(dbId, ',');
        for (String id : dbIds) {
            plans.add(buildOneDirectPlan(sqlType, id, sql, index));
        }
    }

    return plans;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:15,代码来源:CostBasedOptimizer.java

示例11: buildOneDirectPlan

import com.taobao.tddl.common.model.SqlType; //导入依赖的package包/类
private IDataNodeExecutor buildOneDirectPlan(SqlType sqlType, String dbId, String sql, int index) {
    IDataNodeExecutor executor = null;
    switch (sqlType) {
        case UPDATE:
            executor = ASTNodeFactory.getInstance().createUpdate();
            break;
        case DELETE:
            executor = ASTNodeFactory.getInstance().createDelete();
            break;
        case INSERT:
            executor = ASTNodeFactory.getInstance().createInsert();
            break;
        case REPLACE:
            executor = ASTNodeFactory.getInstance().createReplace();
            break;
        case SELECT:
            executor = ASTNodeFactory.getInstance().createQuery();
            break;
        default:
            if (SqlTypeParser.isQuerySqlType(sqlType)) {
                executor = ASTNodeFactory.getInstance().createQuery();
            } else {
                executor = ASTNodeFactory.getInstance().createUpdate();
            }
            break;
    }

    if (executor != null) {
        executor.setSql(sql);
        executor.executeOn(dbId);
    }

    if (index > -1 && executor instanceof IPut) {
        // 添加batch index
        ((IPut) executor).getBatchIndexs().add(index);
    }

    return executor;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:40,代码来源:CostBasedOptimizer.java

示例12: update

import com.taobao.tddl.common.model.SqlType; //导入依赖的package包/类
private UpdateNode update(String sql) throws SqlParserException {
    SqlAnalysisResult sm = parser.parse(sql, false);
    UpdateNode qn = null;
    if (sm.getSqlType() == SqlType.UPDATE) {
        qn = sm.getUpdateNode();
    }

    return qn;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:10,代码来源:SqlParserTest.java

示例13: delete

import com.taobao.tddl.common.model.SqlType; //导入依赖的package包/类
private DeleteNode delete(String sql) throws SqlParserException {
    SqlAnalysisResult sm = parser.parse(sql, false);
    DeleteNode qn = null;
    if (sm.getSqlType() == SqlType.DELETE) {
        qn = sm.getDeleteNode();
    }

    return qn;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:10,代码来源:SqlParserTest.java

示例14: insert

import com.taobao.tddl.common.model.SqlType; //导入依赖的package包/类
private InsertNode insert(String sql) throws SqlParserException {
    SqlAnalysisResult sm = parser.parse(sql, false);
    InsertNode qn = null;
    if (sm.getSqlType() == SqlType.INSERT) {
        qn = sm.getInsertNode();
    }

    return qn;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:10,代码来源:SqlParserTest.java

示例15: put

import com.taobao.tddl.common.model.SqlType; //导入依赖的package包/类
private PutNode put(String sql) throws SqlParserException {
    SqlAnalysisResult sm = parser.parse(sql, false);
    PutNode qn = null;
    if (sm.getSqlType() == SqlType.REPLACE) {
        qn = sm.getReplaceNode();
    }

    return qn;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:10,代码来源:SqlParserTest.java


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