當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。