本文整理汇总了Java中com.taobao.tddl.common.model.SqlType.UPDATE属性的典型用法代码示例。如果您正苦于以下问题:Java SqlType.UPDATE属性的具体用法?Java SqlType.UPDATE怎么用?Java SqlType.UPDATE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.taobao.tddl.common.model.SqlType
的用法示例。
在下文中一共展示了SqlType.UPDATE属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
@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");
}
}
示例2: getAstNode
@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());
}
示例3: update
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;
}
示例4: 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();
}
}
示例5: getAstNode
public ASTNode getAstNode(Map<Integer, ParameterContext> parameterSettings) {
if (sqlType == SqlType.SELECT || sqlType == SqlType.SHOW_WITH_TABLE) {
return getQueryTreeNode(parameterSettings);
} else if (sqlType == SqlType.UPDATE) {
return getUpdateNode(parameterSettings);
} else if (sqlType == SqlType.INSERT) {
return getInsertNode(parameterSettings);
} else if (sqlType == SqlType.REPLACE) {
return getReplaceNode(parameterSettings);
} else if (sqlType == SqlType.DELETE) {
return getDeleteNode(parameterSettings);
}
throw new NotSupportException(sqlType.toString());
}
示例6: update
private UpdateNode update(String sql) throws SqlParserException {
SqlAnalysisResult sm = parser.parse(sql, false);
UpdateNode qn = null;
if (sm.getSqlType() == SqlType.UPDATE) {
qn = sm.getUpdateNode(null);
}
return qn;
}
示例7: executeInternal
private boolean executeInternal(String sql, int autoGeneratedKeys, int[] columnIndexes, String[] columnNames)
throws SQLException {
SqlType sqlType = PreParser.getSqlType(sql);
if (sqlType == SqlType.SELECT || sqlType == SqlType.SELECT_FOR_UPDATE/**
*
* || sqlType == SqlType.SHOW
**/
) {
executeQuery(sql);
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) {
if (autoGeneratedKeys == -1 && columnIndexes == null && columnNames == null) {
executeUpdate(sql);
} else if (autoGeneratedKeys != -1) {
executeUpdate(sql, autoGeneratedKeys);
} else if (columnIndexes != null) {
executeUpdate(sql, columnIndexes);
} else if (columnNames != null) {
executeUpdate(sql, columnNames);
} else {
executeUpdate(sql);
}
return false;
} else {
throw new SQLException("only select, insert, update, delete,replace,truncate,create,drop,load,merge sql is supported");
}
}
示例8: 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;
}
示例9: 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;
}
示例10: getSqlType
/**
* 获得SQL语句种类
*
* @param sql SQL语句
* @throws SQLException 当SQL语句不是SELECT、INSERT、UPDATE、DELETE语句时,抛出异常。
*/
public static SqlType getSqlType(String sql) throws SQLException {
// #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, "show")) {
// ??show 不支持?
// sqlType = SqlType.SHOW;
} 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, "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 {
throw new SQLException("only select, insert, update, delete,replace,truncate,create,drop,load,merge sql is supported");
}
// sqlType = globalCache.setSqlTypeIfAbsent(sql, sqlType);
// }
return sqlType;
}