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


Java ValuesClause类代码示例

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


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

示例1: cloneTo

import com.alibaba.druid.sql.ast.statement.SQLInsertStatement.ValuesClause; //导入依赖的package包/类
public void cloneTo(SQLInsertInto x) {
    if (tableSource != null) {
        x.setTableSource(tableSource.clone());
    }
    for (SQLExpr column : columns) {
        SQLExpr column2 = column.clone();
        column2.setParent(x);
        x.columns.add(column2);
    }
    if (query != null) {
        x.setQuery(query.clone());
    }
    for (ValuesClause v : valuesList) {
        ValuesClause v2 = v.clone();
        v2.setParent(x);
        x.valuesList.add(v2);
    }
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:19,代码来源:SQLInsertInto.java

示例2: setValues

import com.alibaba.druid.sql.ast.statement.SQLInsertStatement.ValuesClause; //导入依赖的package包/类
public void setValues(ValuesClause values) {
    if (valuesList.size() == 0) {
        valuesList.add(values);
    } else {
        valuesList.set(0, values);
    }
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:8,代码来源:SQLInsertInto.java

示例3: visit

import com.alibaba.druid.sql.ast.statement.SQLInsertStatement.ValuesClause; //导入依赖的package包/类
public boolean visit(SQLNullExpr x) {
    if (this.parameterized
            && x.getParent() instanceof ValuesClause) {
        print('?');
        incrementReplaceCunt();

        if(this.parameters != null){
            this.getParameters().add(null);
        }
        return false;
    }

    print0(ucase ? "NULL" : "null");
    return false;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:16,代码来源:SQLASTOutputVisitor.java

示例4: evalInsert

import com.alibaba.druid.sql.ast.statement.SQLInsertStatement.ValuesClause; //导入依赖的package包/类
private static Set<Object> evalInsert(SQLParsedResult parseResult, String column, List<Object> params) {
		Set<Object> evalSet = new LinkedHashSet<Object>();
		MySqlInsertStatement stmt = (MySqlInsertStatement) parseResult.getStmt();

		List<SQLExpr> columns = stmt.getColumns();
		List<ValuesClause> valuesList = stmt.getValuesList();

		if (valuesList.size() > 1) {
			throw new ShardRouterException("Multipal rows insertion is currently unsupported!");
		}

		ValuesClause values = valuesList.get(0);
		for (int i = 0; i < columns.size(); i++) {
			SQLName columnObj = (SQLName) columns.get(i);
			if (evalColumn(columnObj.getSimpleName(), column)) {
				SQLExpr sqlExpr = values.getValues().get(i);
				if (sqlExpr instanceof SQLVariantRefExpr) {
					SQLVariantRefExpr ref = (SQLVariantRefExpr) sqlExpr;
					evalSet.add(params.get(ref.getIndex()));
//					evalSet.add(params.get(i));
				} else if (sqlExpr instanceof SQLValuableExpr) {
					evalSet.add(((SQLValuableExpr) sqlExpr).getValue());
				}
				break;
			}
		}

		return evalSet;
	}
 
开发者ID:dianping,项目名称:zebra,代码行数:30,代码来源:ShardColumnValueUtil.java

示例5: route

import com.alibaba.druid.sql.ast.statement.SQLInsertStatement.ValuesClause; //导入依赖的package包/类
@Override
public void route(SystemConfig sysConfig, SchemaConfig schema, int sqlType,
		String realSQL, String charset, ServerConnection sc,
		LayerCachePool cachePool) {
	int rs = ServerParse.parse(realSQL);
	this.sqltype = rs & 0xff;
	this.sysConfig=sysConfig; 
	this.schema=schema;
	this.charset=charset; 
	this.sc=sc;	
	this.cachePool=cachePool;	
	
	try {
		MySqlStatementParser parser = new MySqlStatementParser(realSQL);	 
		SQLStatement statement = parser.parseStatement();
		MySqlInsertStatement insert = (MySqlInsertStatement)statement;
		if(insert.getValuesList()!=null){
			String tableName = StringUtil.getTableName(realSQL).toUpperCase();
			TableConfig tableConfig = schema.getTables().get(tableName);
			String primaryKey = tableConfig.getPrimaryKey();//获得表的主键字段
			
			SQLIdentifierExpr sqlIdentifierExpr = new SQLIdentifierExpr();
			sqlIdentifierExpr.setName(primaryKey);
			insert.getColumns().add(sqlIdentifierExpr);
			
			if(sequenceHandler == null){
				int seqHandlerType = MycatServer.getInstance().getConfig().getSystem().getSequnceHandlerType();
				switch(seqHandlerType){
					case SystemConfig.SEQUENCEHANDLER_MYSQLDB:
						sequenceHandler = IncrSequenceMySQLHandler.getInstance();
						break;
					case SystemConfig.SEQUENCEHANDLER_LOCALFILE:
						sequenceHandler = IncrSequencePropHandler.getInstance();
						break;
					case SystemConfig.SEQUENCEHANDLER_LOCAL_TIME:
						sequenceHandler = IncrSequenceTimeHandler.getInstance();
						break;
					case SystemConfig.SEQUENCEHANDLER_ZK_DISTRIBUTED:
						sequenceHandler = DistributedSequenceHandler.getInstance(MycatServer.getInstance().getConfig().getSystem());
						break;
					case SystemConfig.SEQUENCEHANDLER_ZK_GLOBAL_INCREMENT:
						sequenceHandler = IncrSequenceZKHandler.getInstance();
						break;
					default:
						throw new java.lang.IllegalArgumentException("Invalid sequnce handler type "+seqHandlerType);
				}
			}
			
			for(ValuesClause vc : insert.getValuesList()){
				SQLIntegerExpr sqlIntegerExpr = new SQLIntegerExpr();
				long value = sequenceHandler.nextId(tableName.toUpperCase());
				sqlIntegerExpr.setNumber(value);//插入生成的sequence值
				vc.addValue(sqlIntegerExpr);
			}
			
			String insertSql = insert.toString();
			this.executeSql = insertSql;
		}
		
	} catch (Exception e) {
		LOGGER.error("BatchInsertSequence.route(......)",e);
	}
}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:64,代码来源:BatchInsertSequence.java

示例6: getValues

import com.alibaba.druid.sql.ast.statement.SQLInsertStatement.ValuesClause; //导入依赖的package包/类
public ValuesClause getValues() {
    if (valuesList.size() == 0) {
        return null;
    }
    return valuesList.get(0);
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:7,代码来源:SQLInsertInto.java

示例7: getValuesList

import com.alibaba.druid.sql.ast.statement.SQLInsertStatement.ValuesClause; //导入依赖的package包/类
public List<ValuesClause> getValuesList() {
    return valuesList;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:4,代码来源:SQLInsertInto.java

示例8: addValueCause

import com.alibaba.druid.sql.ast.statement.SQLInsertStatement.ValuesClause; //导入依赖的package包/类
public void addValueCause(ValuesClause valueClause) {
    if (valueClause != null) {
        valueClause.setParent(this);
    }
    valuesList.add(valueClause);
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:7,代码来源:SQLInsertInto.java

示例9: visit

import com.alibaba.druid.sql.ast.statement.SQLInsertStatement.ValuesClause; //导入依赖的package包/类
@Override
public boolean visit(ValuesClause x) {
    return true;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:5,代码来源:SQLASTVisitorAdapter.java

示例10: convertInsertSQL

import com.alibaba.druid.sql.ast.statement.SQLInsertStatement.ValuesClause; //导入依赖的package包/类
private String convertInsertSQL(SchemaInfo schemaInfo, MySqlInsertStatement insert, String originSql, TableConfig tc,
                                boolean isGlobalCheck) throws SQLNonTransientException {

    StructureMeta.TableMeta orgTbMeta = DbleServer.getInstance().getTmManager().getSyncTableMeta(schemaInfo.getSchema(), schemaInfo.getTable());
    if (orgTbMeta == null)
        return originSql;

    boolean isAutoIncrement = tc.isAutoIncrement();

    if (isGlobalCheck && !GlobalTableUtil.isInnerColExist(schemaInfo, orgTbMeta)) {
        if (!isAutoIncrement) {
            return originSql;
        } else {
            isGlobalCheck = false;
        }
    }

    StringBuilder sb = new StringBuilder(200);
    sb.append("insert ");
    if (insert.isIgnore()) {
        sb.append("ignore ");
    }
    sb.append("into ");
    sb.append(schemaInfo.getTable());

    List<SQLExpr> columns = insert.getColumns();

    int autoIncrement = -1;
    int idxGlobal = -1;
    int colSize;
    // insert without columns :insert into t values(xxx,xxx)
    if (columns == null || columns.size() <= 0) {
        if (isAutoIncrement) {
            autoIncrement = getPrimaryKeyIndex(schemaInfo, tc.getPrimaryKey());
        }
        colSize = orgTbMeta.getColumnsList().size();
        idxGlobal = getIdxGlobalByMeta(isGlobalCheck, orgTbMeta, sb, colSize);
    } else {
        genColumnNames(tc, isGlobalCheck, isAutoIncrement, sb, columns);
        colSize = columns.size();
        if (isAutoIncrement) {
            autoIncrement = columns.size();
            sb.append(",").append(tc.getPrimaryKey());
            colSize++;
        }
        if (isGlobalCheck) {
            idxGlobal = isAutoIncrement ? columns.size() + 1 : columns.size();
            sb.append(",").append(GlobalTableUtil.GLOBAL_TABLE_CHECK_COLUMN);
            colSize++;
        }
        sb.append(")");
    }

    sb.append(" values");
    String tableKey = StringUtil.getFullName(schemaInfo.getSchema(), schemaInfo.getTable());
    List<ValuesClause> vcl = insert.getValuesList();
    if (vcl != null && vcl.size() > 1) { // batch insert
        for (int j = 0; j < vcl.size(); j++) {
            if (j != vcl.size() - 1)
                appendValues(tableKey, vcl.get(j).getValues(), sb, autoIncrement, idxGlobal, colSize).append(",");
            else
                appendValues(tableKey, vcl.get(j).getValues(), sb, autoIncrement, idxGlobal, colSize);
        }
    } else {
        List<SQLExpr> values = insert.getValues().getValues();
        appendValues(tableKey, values, sb, autoIncrement, idxGlobal, colSize);
    }

    List<SQLExpr> dku = insert.getDuplicateKeyUpdate();
    if (dku != null && dku.size() > 0) {
        genDuplicate(isGlobalCheck, sb, dku);
    }
    return RouterUtil.removeSchema(sb.toString(), schemaInfo.getSchema());
}
 
开发者ID:actiontech,项目名称:dble,代码行数:75,代码来源:DruidInsertParser.java

示例11: endVisit

import com.alibaba.druid.sql.ast.statement.SQLInsertStatement.ValuesClause; //导入依赖的package包/类
@Override
public void endVisit(ValuesClause x) {

}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:5,代码来源:SQLASTVisitorAdapter.java


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