本文整理汇总了Java中com.alibaba.druid.sql.dialect.mysql.visitor.MySqlOutputVisitor类的典型用法代码示例。如果您正苦于以下问题:Java MySqlOutputVisitor类的具体用法?Java MySqlOutputVisitor怎么用?Java MySqlOutputVisitor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MySqlOutputVisitor类属于com.alibaba.druid.sql.dialect.mysql.visitor包,在下文中一共展示了MySqlOutputVisitor类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: buildTableName
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlOutputVisitor; //导入依赖的package包/类
protected void buildTableName(TableNode tableNode, StringBuilder sb) {
sb.append(" `").append(tableNode.getPureName()).append("`");
String alias = tableNode.getAlias();
if (alias != null) {
sb.append(" `").append(alias).append("`");
}
List<SQLHint> hintList = tableNode.getHintList();
if (hintList != null && !hintList.isEmpty()) {
sb.append(' ');
boolean isFirst = true;
for (SQLHint hint : hintList) {
if (isFirst)
isFirst = false;
else
sb.append(" ");
MySqlOutputVisitor ov = new MySqlOutputVisitor(sb);
hint.accept(ov);
}
}
}
开发者ID:actiontech,项目名称:dble,代码行数:21,代码来源:MysqlVisitor.java
示例2: changeSql
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlOutputVisitor; //导入依赖的package包/类
@Override
public void changeSql(ParseResult result, ExecutePlan plan) {
if (ExecuteType.NO == plan.getExecuteType()){
}else {
for (TrargetSqlEntity sql : plan.getSqlList()){
ReplaceTableNameVisitor replaceVisitor = new ReplaceTableNameVisitor(sql.getLogicTableName(), sql.getTargetTableName());
StringBuilder out = new StringBuilder();
MySqlOutputVisitor outPutVisitor = new MySqlOutputVisitor(out);
// 替换表名
statement.accept(replaceVisitor);
// 输出sql
statement.accept(outPutVisitor);
sql.setOriginalSql(result.getSql());
sql.setTargetSql(out.toString());
// 输出sql后要还原statement以便下次替换表名
replaceVisitor.reset();
}
}
}
开发者ID:tongbanjie,项目名称:baymax,代码行数:20,代码来源:MySqlSqlParser.java
示例3: test
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlOutputVisitor; //导入依赖的package包/类
public void test(String sql, String logicName, String targetName){
MySqlStatementParser parser = new MySqlStatementParser(sql);
SQLStatement statement = parser.parseStatement();
ReplaceTableNameVisitor replaceVisitor = new ReplaceTableNameVisitor(logicName, targetName);
StringBuilder out = new StringBuilder();
MySqlOutputVisitor outPutVisitor = new MySqlOutputVisitor(out);
// 替换表名
statement.accept(replaceVisitor);
// 输出sql
statement.accept(outPutVisitor);
System.out.println();
System.out.println(sql);
System.out.println(out.toString());
// 输出sql后要还原statement以便下次替换表名
replaceVisitor.reset();
}
开发者ID:tongbanjie,项目名称:baymax,代码行数:20,代码来源:ReplaceTableNameVisitorTest.java
示例4: createParameterizedOutputVisitor
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlOutputVisitor; //导入依赖的package包/类
public static ParameterizedVisitor createParameterizedOutputVisitor(Appendable out, String dbType) {
if (JdbcConstants.ORACLE.equals(dbType) || JdbcConstants.ALI_ORACLE.equals(dbType)) {
return new OracleParameterizedOutputVisitor(out);
}
if (JdbcConstants.MYSQL.equals(dbType)
|| JdbcConstants.MARIADB.equals(dbType)
|| JdbcConstants.H2.equals(dbType)) {
return new MySqlOutputVisitor(out, true);
}
if (JdbcConstants.POSTGRESQL.equals(dbType)
|| JdbcConstants.ENTERPRISEDB.equals(dbType)) {
return new PGOutputVisitor(out, true);
}
if (JdbcConstants.SQL_SERVER.equals(dbType) || JdbcConstants.JTDS.equals(dbType)) {
return new SQLServerOutputVisitor(out, true);
}
if (JdbcConstants.DB2.equals(dbType)) {
return new DB2OutputVisitor(out, true);
}
if (JdbcConstants.PHOENIX.equals(dbType)) {
return new PhoenixOutputVisitor(out, true);
}
if (JdbcConstants.ELASTIC_SEARCH.equals(dbType)) {
return new MySqlOutputVisitor(out, true);
}
return new SQLASTOutputVisitor(out, true);
}
开发者ID:zuonima,项目名称:sql-utils,代码行数:35,代码来源:ParameterizedOutputVisitorUtils.java
示例5: makeColumnMeta
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlOutputVisitor; //导入依赖的package包/类
public static StructureMeta.ColumnMeta.Builder makeColumnMeta(StructureMeta.TableMeta.Builder tmBuilder, SQLColumnDefinition column, Set<String> indexNames) {
StructureMeta.ColumnMeta.Builder cmBuilder = StructureMeta.ColumnMeta.newBuilder();
cmBuilder.setName(StringUtil.removeBackQuote(column.getName().getSimpleName()));
cmBuilder.setDataType(column.getDataType().getName());
for (SQLColumnConstraint constraint : column.getConstraints()) {
if (constraint instanceof SQLNotNullConstraint) {
cmBuilder.setCanNull(false);
} else if (constraint instanceof SQLNullConstraint) {
cmBuilder.setCanNull(true);
} else if (constraint instanceof SQLColumnPrimaryKey) {
tmBuilder.setPrimary(makeIndexMeta(PRIMARY, IndexType.PRI, new ArrayList<SQLExpr>(Collections.singletonList(column.getName()))));
} else if (constraint instanceof SQLColumnUniqueKey) {
List<SQLExpr> columnExprs = new ArrayList<SQLExpr>(Collections.singletonList(column.getName()));
String indexName = genIndexName(null, columnExprs, indexNames);
tmBuilder.addUniIndex(makeIndexMeta(indexName, IndexType.UNI, columnExprs));
}
}
if (column.getDefaultExpr() != null) {
StringBuilder builder = new StringBuilder();
MySqlOutputVisitor visitor = new MySqlOutputVisitor(builder);
column.getDefaultExpr().accept(visitor);
cmBuilder.setSdefault(builder.toString());
}
if (column.isAutoIncrement()) {
cmBuilder.setAutoIncre(true);
}
return cmBuilder;
}
开发者ID:actiontech,项目名称:dble,代码行数:29,代码来源:MetaHelper.java
示例6: getItemName
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlOutputVisitor; //导入依赖的package包/类
public final String getItemName() {
if (itemName == null || itemName.length() == 0) {
SQLExpr expr = toExpression();
StringBuilder sb = new StringBuilder();
MySqlOutputVisitor ov = new MySqlOutputVisitor(sb);
expr.accept(ov);
itemName = sb.toString();
}
return itemName;
}
开发者ID:actiontech,项目名称:dble,代码行数:11,代码来源:Item.java
示例7: test
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlOutputVisitor; //导入依赖的package包/类
/**
* //agg
* getMergeColumns
* getAliaColumns
*
* //group by
* setGroupbyColumns
*
* @param sql
*/
public void test(String sql){
ParseResult result = new ParseResult();
ExecutePlan plan = new ExecutePlan();
parser.init(sql, null);
parser.parse(result);
plan.setExecuteType(ExecuteType.PARTITION);
SQLSelectStatement stmt = (SQLSelectStatement) parser.statement;
parser.parseMysqlQueary(result, plan, (MySqlSelectQueryBlock) stmt.getSelect().getQuery());
StringBuilder out = new StringBuilder();
MySqlOutputVisitor outPutVisitor = new MySqlOutputVisitor(out);
stmt.accept(outPutVisitor);
System.out.println();
System.out.println("/***********************agg*************************/");
System.out.println(plan.getMergeColumns());
System.out.println("setHasAllColumnExpr:" + result.isHasAllColumnExpr());
System.out.println(out.toString());
PrintUtil.printFildAlisMap(result.getAliaColumns());
System.out.println("/*********************group by**********************/");
System.out.println(plan.getGroupbyColumns());
System.out.println("/*********************order by**********************/");
System.out.println(plan.getOrderbyColumns());
}
开发者ID:tongbanjie,项目名称:baymax,代码行数:40,代码来源:MySqlSelectAggParserTest.java
示例8: createFormatOutputVisitor
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlOutputVisitor; //导入依赖的package包/类
public static SQLASTOutputVisitor createFormatOutputVisitor(Appendable out, //
List<SQLStatement> statementList, //
String dbType) {
if (JdbcConstants.ORACLE.equals(dbType) || JdbcConstants.ALI_ORACLE.equals(dbType)) {
if (statementList == null || statementList.size() == 1) {
return new OracleOutputVisitor(out, false);
} else {
return new OracleOutputVisitor(out, true);
}
}
if (JdbcConstants.MYSQL.equals(dbType) //
|| JdbcConstants.MARIADB.equals(dbType)) {
return new MySqlOutputVisitor(out);
}
if (JdbcConstants.POSTGRESQL.equals(dbType)) {
return new PGOutputVisitor(out);
}
if (JdbcConstants.SQL_SERVER.equals(dbType) || JdbcConstants.JTDS.equals(dbType)) {
return new SQLServerOutputVisitor(out);
}
if (JdbcConstants.DB2.equals(dbType)) {
return new DB2OutputVisitor(out);
}
if (JdbcConstants.ODPS.equals(dbType)) {
return new OdpsOutputVisitor(out);
}
if (JdbcConstants.H2.equals(dbType)) {
return new H2OutputVisitor(out);
}
if (JdbcConstants.HIVE.equals(dbType)) {
return new HiveOutputVisitor(out);
}
if (JdbcConstants.ELASTIC_SEARCH.equals(dbType)) {
return new MySqlOutputVisitor(out);
}
return new SQLASTOutputVisitor(out, dbType);
}
开发者ID:zuonima,项目名称:sql-utils,代码行数:47,代码来源:SQLUtils.java
示例9: output
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlOutputVisitor; //导入依赖的package包/类
public void output(StringBuffer buf) {
new MySqlOutputVisitor(buf).visit(this);
}
开发者ID:zuonima,项目名称:sql-utils,代码行数:4,代码来源:MySqlInsertStatement.java
示例10: output
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlOutputVisitor; //导入依赖的package包/类
public void output(StringBuffer buf) {
this.accept(new MySqlOutputVisitor(buf));
}
开发者ID:zuonima,项目名称:sql-utils,代码行数:4,代码来源:MySqlCreateTableStatement.java
示例11: initName
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlOutputVisitor; //导入依赖的package包/类
private void initName(SQLExpr expr) {
StringBuilder sb = new StringBuilder();
MySqlOutputVisitor ov = new MySqlOutputVisitor(sb);
expr.accept(ov);
item.setItemName(sb.toString());
}
开发者ID:actiontech,项目名称:dble,代码行数:7,代码来源:MySQLItemVisitor.java
注:本文中的com.alibaba.druid.sql.dialect.mysql.visitor.MySqlOutputVisitor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论