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


Java SqlType.EXPLAIN属性代码示例

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


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

示例1: isQuerySqlType

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,代码行数:10,代码来源:SqlTypeParser.java

示例2: isQuerySql

public static boolean isQuerySql(String sql) {
    SqlType sqlType = getSqlType(sql);
    if (sqlType == SqlType.SELECT || sqlType == SqlType.SELECT_FOR_UPDATE || sqlType == SqlType.SHOW
        || sqlType == SqlType.DUMP || sqlType == SqlType.DEBUG || sqlType == SqlType.EXPLAIN) {
        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
               || sqlType == SqlType.ALTER || sqlType == SqlType.RENAME) {
        return false;
    } else {
        return throwNotSupportSqlTypeException();
    }
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:14,代码来源:SqlTypeParser.java

示例3: getSqlType

/**
 * 获得SQL语句种类
 * 
 * @param sql SQL语句
 * @throws 当SQL语句不是SELECT、INSERT、UPDATE、DELETE语句时,抛出异常。
 */
public static SqlType getSqlType(String sql) {
    // #bug 2011-11-24,modify by junyu,先不走缓存,否则sql变化巨大,缓存换入换出太多,gc太明显
    // SqlType sqlType = globalCache.getSqlType(sql);
    // if (sqlType == null) {
    SqlType sqlType = null;
    // #bug 2011-12-8,modify by junyu ,this code use huge cpu resource,and
    // most sql have no comment,so first simple look for there whether have
    // the comment

    String noCommentsSql = sql;
    if (sql.contains("/*")) {
        noCommentsSql = TStringUtil.stripComments(sql, "'\"", "'\"", true, false, true, true).trim();
    }

    if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "select")) {
        // #bug 2011-12-9,this select-for-update regex has low
        // performance,so
        // first judge this sql whether have ' for ' string.
        if (noCommentsSql.toLowerCase().contains(" for ")
            && SELECT_FOR_UPDATE_PATTERN.matcher(noCommentsSql).matches()) {
            sqlType = SqlType.SELECT_FOR_UPDATE;
        } else {
            sqlType = SqlType.SELECT;
        }
    } else if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "insert")) {
        sqlType = SqlType.INSERT;
    } else if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "update")) {
        sqlType = SqlType.UPDATE;
    } else if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "delete")) {
        sqlType = SqlType.DELETE;
    } else if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "show")) {
        sqlType = SqlType.SHOW;
    } else if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "replace")) {
        sqlType = SqlType.REPLACE;
    } else if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "truncate")) {
        sqlType = SqlType.TRUNCATE;
    } else if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "create")) {
        sqlType = SqlType.CREATE;
    } else if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "drop")) {
        sqlType = SqlType.DROP;
    } else if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "load")) {
        sqlType = SqlType.LOAD;
    } else if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "merge")) {
        sqlType = SqlType.MERGE;
    } else if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "alter")) {
        sqlType = SqlType.ALTER;
    } else if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "rename")) {
        sqlType = SqlType.RENAME;
    } else if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "dump")) {
        sqlType = SqlType.DUMP;
    } else if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "debug")) {
        sqlType = SqlType.DEBUG;
    } else if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "explain")) {
        sqlType = SqlType.EXPLAIN;
    } else if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "desc")) {
        sqlType = SqlType.DESC;
    } else if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "call")
               || CALL_PATTERN.matcher(noCommentsSql).matches()) {
        sqlType = SqlType.PROCEDURE;
    } else if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "set")) {
        sqlType = SqlType.SET;
    } else {
        throw new NotSupportException("SqlType is Not Support");
    }
    return sqlType;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:72,代码来源:SqlTypeParser.java

示例4: getSqlType

/**
 * 获得SQL语句种类
 * 
 * @param sql SQL语句
 * @throws 当SQL语句不是SELECT、INSERT、UPDATE、DELETE语句时,抛出异常。
 */
public static SqlType getSqlType(String sql) {
    // #bug 2011-11-24,modify by junyu,先不走缓存,否则sql变化巨大,缓存换入换出太多,gc太明显
    // SqlType sqlType = globalCache.getSqlType(sql);
    // if (sqlType == null) {
    SqlType sqlType = null;
    // #bug 2011-12-8,modify by junyu ,this code use huge cpu resource,and
    // most sql have no comment,so first simple look for there whether have
    // the comment

    String noCommentsSql = sql;
    if (sql.contains("/*")) {
        noCommentsSql = TStringUtil.stripComments(sql, "'\"", "'\"", true, false, true, true).trim();
    }

    if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "select")) {
        // #bug 2011-12-9,this select-for-update regex has low
        // performance,so
        // first judge this sql whether have ' for ' string.
        if (noCommentsSql.toLowerCase().contains(" for ")
            && SELECT_FOR_UPDATE_PATTERN.matcher(noCommentsSql).matches()) {
            sqlType = SqlType.SELECT_FOR_UPDATE;
        } else {
            sqlType = SqlType.SELECT;
        }
    } else if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "insert")) {
        sqlType = SqlType.INSERT;
    } else if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "update")) {
        sqlType = SqlType.UPDATE;
    } else if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "delete")) {
        sqlType = SqlType.DELETE;
    } else if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "show")) {
        sqlType = SqlType.SHOW;
    } else if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "replace")) {
        sqlType = SqlType.REPLACE;
    } else if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "truncate")) {
        sqlType = SqlType.TRUNCATE;
    } else if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "create")) {
        sqlType = SqlType.CREATE;
    } else if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "drop")) {
        sqlType = SqlType.DROP;
    } else if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "load")) {
        sqlType = SqlType.LOAD;
    } else if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "merge")) {
        sqlType = SqlType.MERGE;
    } else if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "alter")) {
        sqlType = SqlType.ALTER;
    } else if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "rename")) {
        sqlType = SqlType.RENAME;
    } else if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "dump")) {
        sqlType = SqlType.DUMP;
    } else if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "debug")) {
        sqlType = SqlType.DEBUG;
    } else if (TStringUtil.startsWithIgnoreCaseAndWs(noCommentsSql, "explain")) {
        sqlType = SqlType.EXPLAIN;
    } else {
        throwNotSupportSqlTypeException();
    }
    return sqlType;
}
 
开发者ID:beebeandwer,项目名称:TDDL,代码行数:65,代码来源:SqlTypeParser.java


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