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


Java SQLDeleteStatement类代码示例

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


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

示例1: SQLDeleteBuilderImpl

import com.alibaba.druid.sql.ast.statement.SQLDeleteStatement; //导入依赖的package包/类
public SQLDeleteBuilderImpl(String sql, String dbType){
    List<SQLStatement> stmtList = SQLUtils.parseStatements(sql, dbType);

    if (stmtList.size() == 0) {
        throw new IllegalArgumentException("not support empty-statement :" + sql);
    }

    if (stmtList.size() > 1) {
        throw new IllegalArgumentException("not support multi-statement :" + sql);
    }

    SQLDeleteStatement stmt = (SQLDeleteStatement) stmtList.get(0);
    this.stmt = stmt;
    this.dbType = dbType;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:16,代码来源:SQLDeleteBuilderImpl.java

示例2: where

import com.alibaba.druid.sql.ast.statement.SQLDeleteStatement; //导入依赖的package包/类
@Override
public SQLDeleteBuilder where(String expr) {
    SQLDeleteStatement delete = getSQLDeleteStatement();

    SQLExpr exprObj = SQLUtils.toSQLExpr(expr, dbType);
    delete.setWhere(exprObj);

    return this;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:10,代码来源:SQLDeleteBuilderImpl.java

示例3: whereAnd

import com.alibaba.druid.sql.ast.statement.SQLDeleteStatement; //导入依赖的package包/类
@Override
public SQLDeleteBuilder whereAnd(String expr) {
    SQLDeleteStatement delete = getSQLDeleteStatement();

    SQLExpr exprObj = SQLUtils.toSQLExpr(expr, dbType);
    SQLExpr newCondition = SQLUtils.buildCondition(SQLBinaryOperator.BooleanAnd, exprObj, false, delete.getWhere());
    delete.setWhere(newCondition);

    return this;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:11,代码来源:SQLDeleteBuilderImpl.java

示例4: whereOr

import com.alibaba.druid.sql.ast.statement.SQLDeleteStatement; //导入依赖的package包/类
@Override
public SQLDeleteBuilder whereOr(String expr) {
    SQLDeleteStatement delete = getSQLDeleteStatement();

    SQLExpr exprObj = SQLUtils.toSQLExpr(expr, dbType);
    SQLExpr newCondition = SQLUtils.buildCondition(SQLBinaryOperator.BooleanOr, exprObj, false, delete.getWhere());
    delete.setWhere(newCondition);

    return this;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:11,代码来源:SQLDeleteBuilderImpl.java

示例5: createSQLDeleteStatement

import com.alibaba.druid.sql.ast.statement.SQLDeleteStatement; //导入依赖的package包/类
public SQLDeleteStatement createSQLDeleteStatement() {
    if (JdbcConstants.ORACLE.equals(dbType)) {
        return new OracleDeleteStatement();    
    }
    
    if (JdbcConstants.MYSQL.equals(dbType)) {
        return new MySqlDeleteStatement();    
    }
    
    if (JdbcConstants.POSTGRESQL.equals(dbType)) {
        return new PGDeleteStatement();    
    }
    
    return new SQLDeleteStatement();
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:16,代码来源:SQLDeleteBuilderImpl.java

示例6: create

import com.alibaba.druid.sql.ast.statement.SQLDeleteStatement; //导入依赖的package包/类
/**
 * Create the compatible Query object
 * based on the SQL query.
 *
 * @param sql The SQL query.
 * @return Query object.
 */
public static QueryAction create(Client client, String sql) throws SqlParseException, SQLFeatureNotSupportedException {
	sql = sql.replaceAll("\n"," ");
       String firstWord = sql.substring(0, sql.indexOf(' '));
       switch (firstWord.toUpperCase()) {
		case "SELECT":
			SQLQueryExpr sqlExpr = (SQLQueryExpr) toSqlExpr(sql);
               if(isMulti(sqlExpr)){
                   MultiQuerySelect multiSelect = new SqlParser().parseMultiSelect((SQLUnionQuery) sqlExpr.getSubQuery().getQuery());
                   handleSubQueries(client,multiSelect.getFirstSelect());
                   handleSubQueries(client,multiSelect.getSecondSelect());
                   return new MultiQueryAction(client, multiSelect);
               }
               else if(isJoin(sqlExpr,sql)){
                   JoinSelect joinSelect = new SqlParser().parseJoinSelect(sqlExpr);
                   handleSubQueries(client, joinSelect.getFirstTable());
                   handleSubQueries(client, joinSelect.getSecondTable());
                   return ESJoinQueryActionFactory.createJoinAction(client, joinSelect);
               }
               else {
                   Select select = new SqlParser().parseSelect(sqlExpr);
                   handleSubQueries(client, select);
                   return handleSelect(client, select);
               }
		case "DELETE":
               SQLStatementParser parser = createSqlStatementParser(sql);
			SQLDeleteStatement deleteStatement = parser.parseDeleteStatement();
			Delete delete = new SqlParser().parseDelete(deleteStatement);
			return new DeleteQueryAction(client, delete);
           case "SHOW":
               return new ShowQueryAction(client,sql);
		default:
			throw new SQLFeatureNotSupportedException(String.format("Unsupported query: %s", sql));
	}
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:42,代码来源:ESActionFactory.java

示例7: getType

import com.alibaba.druid.sql.ast.statement.SQLDeleteStatement; //导入依赖的package包/类
@Override
public SqlType getType() {
    if (sqlStatement instanceof SQLSelectStatement)
        return SqlType.SELECT;
    if (sqlStatement instanceof SQLUpdateStatement) return SqlType.UPDATE;

    if (sqlStatement instanceof SQLInsertStatement)

        return SqlType.INSERT;
    if (sqlStatement instanceof SQLDeleteStatement)
        return SqlType.DELETE;
    return null;
}
 
开发者ID:maniaclee,项目名称:shardy,代码行数:14,代码来源:DruidSqlParser.java

示例8: getStatementType

import com.alibaba.druid.sql.ast.statement.SQLDeleteStatement; //导入依赖的package包/类
public SQLStatementType getStatementType() {
    if (sqlStatement instanceof SQLSelectStatement) {
        return SQLStatementType.SELECT;
    }
    if (sqlStatement instanceof SQLInsertStatement) {
        return SQLStatementType.INSERT;
    }
    if (sqlStatement instanceof SQLUpdateStatement) {
        return SQLStatementType.UPDATE;
    }
    if (sqlStatement instanceof SQLDeleteStatement) {
        return SQLStatementType.DELETE;
    }
    throw new SQLParserException("Unsupported SQL statement: [%s]", sqlStatement);
}
 
开发者ID:balancebeam,项目名称:sherlock,代码行数:16,代码来源:SQLParseEngine.java

示例9: getSQLVisitor

import com.alibaba.druid.sql.ast.statement.SQLDeleteStatement; //导入依赖的package包/类
private static SQLASTOutputVisitor getSQLVisitor(DatabaseType databaseType,SQLStatement sqlStatement) {
    if (sqlStatement instanceof SQLSelectStatement) {
        return ClassUtil.newInstance(SQLVisitorRegistry.getSelectVistor(databaseType));
    }
    if (sqlStatement instanceof SQLInsertStatement) {
        return ClassUtil.newInstance(SQLVisitorRegistry.getInsertVistor(databaseType));
    }
    if (sqlStatement instanceof SQLUpdateStatement) {
        return ClassUtil.newInstance(SQLVisitorRegistry.getUpdateVistor(databaseType));
    }
    if (sqlStatement instanceof SQLDeleteStatement) {
        return ClassUtil.newInstance(SQLVisitorRegistry.getDeleteVistor(databaseType));
    }
    throw new SQLParserException("Unsupported SQL statement: [%s]", sqlStatement);
}
 
开发者ID:balancebeam,项目名称:sherlock,代码行数:16,代码来源:SQLParserFactory.java

示例10: getOwnerTableName

import com.alibaba.druid.sql.ast.statement.SQLDeleteStatement; //导入依赖的package包/类
/**
     * 从between语句中获取字段所属的表名。
     * 对于容易出现ambiguous的(字段不知道到底属于哪个表),实际应用中必须使用别名来避免歧义
     * @param betweenExpr
     * @param column
     * @return
     */
    private String getOwnerTableName(SQLBetweenExpr betweenExpr,String column) {
        if(tableStats.size() == 1) {//只有一个表,直接返回这一个表名
            return tableStats.keySet().iterator().next().getName();
        } else if(tableStats.size() == 0) {//一个表都没有,返回空串
            return "";
        } else {//多个表名
            for (Column col : columns.keySet())
            {
                if(col.getName().equals(column)) {
                    return col.getTable();
                }
            }
//            for(Column col : columns) {//从columns中找表名
//                if(col.getName().equals(column)) {
//                    return col.getTable();
//                }
//            }

            //前面没找到表名的,自己从parent中解析

            SQLObject parent = betweenExpr.getParent();
            if(parent instanceof SQLBinaryOpExpr)
            {
                parent=parent.getParent();
            }

            if(parent instanceof MySqlSelectQueryBlock) {
                MySqlSelectQueryBlock select = (MySqlSelectQueryBlock) parent;
                if(select.getFrom() instanceof SQLJoinTableSource) {//多表连接
                    SQLJoinTableSource joinTableSource = (SQLJoinTableSource)select.getFrom();
                    return joinTableSource.getLeft().toString();//将left作为主表,此处有不严谨处,但也是实在没有办法,如果要准确,字段前带表名或者表的别名即可
                } else if(select.getFrom() instanceof SQLExprTableSource) {//单表
                    return select.getFrom().toString();
                }
            }
            else if(parent instanceof SQLUpdateStatement) {
                SQLUpdateStatement update = (SQLUpdateStatement) parent;
                return update.getTableName().getSimpleName();
            } else if(parent instanceof SQLDeleteStatement) {
                SQLDeleteStatement delete = (SQLDeleteStatement) parent;
                return delete.getTableName().getSimpleName();
            } else {
                
            }
        }
        return "";
    }
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:55,代码来源:MycatSchemaStatVisitor.java

示例11: getSQLDeleteStatement

import com.alibaba.druid.sql.ast.statement.SQLDeleteStatement; //导入依赖的package包/类
public SQLDeleteStatement getSQLDeleteStatement() {
    if (stmt == null) {
        stmt = createSQLDeleteStatement();
    }
    return stmt;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:7,代码来源:SQLDeleteBuilderImpl.java

示例12: WhereParser

import com.alibaba.druid.sql.ast.statement.SQLDeleteStatement; //导入依赖的package包/类
public WhereParser(SqlParser sqlParser, SQLDeleteStatement delete) {
    this.sqlParser = sqlParser;
    this.delete = delete;
    this.where = delete.getWhere();
}
 
开发者ID:NLPchina,项目名称:elasticsearch-sql,代码行数:6,代码来源:WhereParser.java


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