• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SQLSelectQuery类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: statementParse

import com.alibaba.druid.sql.ast.statement.SQLSelectQuery; //导入依赖的package包/类
@Override
	public void statementParse(SchemaConfig schema, RouteResultset rrs, SQLStatement stmt) {
		SQLSelectStatement selectStmt = (SQLSelectStatement)stmt;
		SQLSelectQuery sqlSelectQuery = selectStmt.getSelect().getQuery();
		if(sqlSelectQuery instanceof MySqlSelectQueryBlock) {
			MySqlSelectQueryBlock mysqlSelectQuery = (MySqlSelectQueryBlock)selectStmt.getSelect().getQuery();

				 parseOrderAggGroupMysql(schema, stmt,rrs, mysqlSelectQuery);
				 //更改canRunInReadDB属性
				 if ((mysqlSelectQuery.isForUpdate() || mysqlSelectQuery.isLockInShareMode()) && rrs.isAutocommit() == false)
				 {
					 rrs.setCanRunInReadDB(false);
				 }

		} else if (sqlSelectQuery instanceof MySqlUnionQuery) { 
//			MySqlUnionQuery unionQuery = (MySqlUnionQuery)sqlSelectQuery;
//			MySqlSelectQueryBlock left = (MySqlSelectQueryBlock)unionQuery.getLeft();
//			MySqlSelectQueryBlock right = (MySqlSelectQueryBlock)unionQuery.getLeft();
//			System.out.println();
		}
	}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:22,代码来源:DruidSelectParser.java


示例2: isConditionAlwaysTrue

import com.alibaba.druid.sql.ast.statement.SQLSelectQuery; //导入依赖的package包/类
private boolean isConditionAlwaysTrue(SQLStatement statement) {
	SQLSelectStatement selectStmt = (SQLSelectStatement)statement;
	SQLSelectQuery sqlSelectQuery = selectStmt.getSelect().getQuery();
	if(sqlSelectQuery instanceof MySqlSelectQueryBlock) {
		MySqlSelectQueryBlock mysqlSelectQuery = (MySqlSelectQueryBlock)selectStmt.getSelect().getQuery();
		SQLExpr expr = mysqlSelectQuery.getWhere();
		
		Object o = WallVisitorUtils.getValue(expr);
		if(Boolean.TRUE.equals(o)) {
			return true;
		}
		return false;
	} else {//union
		return false;
	}
	
}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:18,代码来源:DruidSelectParser.java


示例3: statementParse

import com.alibaba.druid.sql.ast.statement.SQLSelectQuery; //导入依赖的package包/类
@Override
public void statementParse(SchemaConfig schema, RouteResultset rrs, SQLStatement stmt) {
	SQLSelectStatement selectStmt = (SQLSelectStatement)stmt;
	SQLSelectQuery sqlSelectQuery = selectStmt.getSelect().getQuery();
      //从mysql解析过来
	if(sqlSelectQuery instanceof MySqlSelectQueryBlock) {
		MySqlSelectQueryBlock mysqlSelectQuery = (MySqlSelectQueryBlock)selectStmt.getSelect().getQuery();
		Limit limit=mysqlSelectQuery.getLimit();
		if(limit==null)
		{
			  //使用oracle的解析,否则会有部分oracle语法识别错误
			  OracleStatementParser oracleParser = new OracleStatementParser(getCtx().getSql());
			  SQLSelectStatement oracleStmt = (SQLSelectStatement) oracleParser.parseStatement();
               selectStmt= oracleStmt;
			  SQLSelectQuery oracleSqlSelectQuery = oracleStmt.getSelect().getQuery();
			  if(oracleSqlSelectQuery instanceof OracleSelectQueryBlock)
			  {
				  parseNativePageSql(oracleStmt, rrs, (OracleSelectQueryBlock) oracleSqlSelectQuery, schema);
			  }



		  }
		if(isNeedParseOrderAgg)
		{
			parseOrderAggGroupMysql(schema, selectStmt,rrs, mysqlSelectQuery);
			//更改canRunInReadDB属性
			if ((mysqlSelectQuery.isForUpdate() || mysqlSelectQuery.isLockInShareMode()) && rrs.isAutocommit() == false)
			{
				rrs.setCanRunInReadDB(false);
			}
		}

	}


}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:38,代码来源:DruidSelectOracleParser.java


示例4: sqlserverParse

import com.alibaba.druid.sql.ast.statement.SQLSelectQuery; //导入依赖的package包/类
private void sqlserverParse(SchemaConfig schema, RouteResultset rrs)
{
    //使用sqlserver的解析,否则会有部分语法识别错误
    SQLServerStatementParser oracleParser = new SQLServerStatementParser(getCtx().getSql());
    SQLSelectStatement oracleStmt = (SQLSelectStatement) oracleParser.parseStatement();
    SQLSelectQuery oracleSqlSelectQuery = oracleStmt.getSelect().getQuery();
    if(oracleSqlSelectQuery instanceof SQLServerSelectQueryBlock)
    {
        parseSqlServerPageSql(oracleStmt, rrs, (SQLServerSelectQueryBlock) oracleSqlSelectQuery, schema);
        if(isNeedParseOrderAgg)
        {
            parseOrderAggGroupSqlServer(schema, oracleStmt,rrs, (SQLServerSelectQueryBlock) oracleSqlSelectQuery);
        }
    }

}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:17,代码来源:DruidSelectSqlServerParser.java


示例5: isSupportSelect

import com.alibaba.druid.sql.ast.statement.SQLSelectQuery; //导入依赖的package包/类
private static boolean isSupportSelect(String stmt) {
    SQLStatementParser parser = new MySqlStatementParser(stmt);
    SQLStatement statement = parser.parseStatement();
    if (!(statement instanceof SQLSelectStatement)) {
        return false;
    }

    SQLSelectQuery sqlSelectQuery = ((SQLSelectStatement) statement).getSelect().getQuery();
    if (!(sqlSelectQuery instanceof MySqlSelectQueryBlock)) {
        return false;
    }
    MySqlSelectQueryBlock selectQueryBlock = (MySqlSelectQueryBlock) sqlSelectQuery;
    SQLTableSource mysqlFrom = selectQueryBlock.getFrom();
    if (mysqlFrom != null) {
        return false;
    }
    for (SQLSelectItem item : selectQueryBlock.getSelectList()) {
        SQLExpr selectItem = item.getExpr();
        if (!isVariantRef(selectItem)) {
            return false;
        }
    }
    return true;
}
 
开发者ID:actiontech,项目名称:dble,代码行数:25,代码来源:SelectHandler.java


示例6: route

import com.alibaba.druid.sql.ast.statement.SQLSelectQuery; //导入依赖的package包/类
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 {
	 //  RouteStrategy routes=RouteStrategyFactory.getRouteStrategy();	
	  // rrs =RouteStrategyFactory.getRouteStrategy().route(sysConfig, schema, sqlType2, realSQL,charset, sc, cachePool);		   
		MySqlStatementParser parser = new MySqlStatementParser(realSQL);			
		SQLStatement statement = parser.parseStatement();
		if(statement instanceof SQLSelectStatement) {
		   SQLSelectStatement st=(SQLSelectStatement)statement;
		   SQLSelectQuery sqlSelectQuery =st.getSelect().getQuery();
			if(sqlSelectQuery instanceof MySqlSelectQueryBlock) {
				MySqlSelectQueryBlock mysqlSelectQuery = (MySqlSelectQueryBlock)st.getSelect().getQuery();
				joinParser=new JoinParser(mysqlSelectQuery,realSQL);
				joinParser.parser();
			}	
		}
	   /*	
	   if (routes instanceof DruidMysqlRouteStrategy) {
		   SQLSelectStatement st=((DruidMysqlRouteStrategy) routes).getSQLStatement();
		   SQLSelectQuery sqlSelectQuery =st.getSelect().getQuery();
			if(sqlSelectQuery instanceof MySqlSelectQueryBlock) {
				MySqlSelectQueryBlock mysqlSelectQuery = (MySqlSelectQueryBlock)st.getSelect().getQuery();
				joinParser=new JoinParser(mysqlSelectQuery,realSQL);
				joinParser.parser();
			}
	   }
	   */
	} catch (Exception e) {
	
	}
}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:38,代码来源:ShareJoin.java


示例7: parseThreeLevelPageSql

import com.alibaba.druid.sql.ast.statement.SQLSelectQuery; //导入依赖的package包/类
private void parseThreeLevelPageSql(SQLStatement stmt, RouteResultset rrs, SchemaConfig schema, SQLSubqueryTableSource from, SQLBinaryOpExpr one, SQLBinaryOperator operator)
{
       SQLIntegerExpr right = (SQLIntegerExpr) one.getRight();
	int firstrownum = right.getNumber().intValue();
	if (operator == SQLBinaryOperator.GreaterThanOrEqual&&firstrownum!=0) {
		firstrownum = firstrownum - 1;
	}
	SQLSelectQuery subSelect = from.getSelect().getQuery();
	if (subSelect instanceof OracleSelectQueryBlock)
       {  //第二层子查询
           OracleSelectQueryBlock twoSubSelect = (OracleSelectQueryBlock) subSelect;
           if (twoSubSelect.getWhere() instanceof SQLBinaryOpExpr && twoSubSelect.getFrom() instanceof SQLSubqueryTableSource)
           {
               SQLBinaryOpExpr twoWhere = (SQLBinaryOpExpr) twoSubSelect.getWhere();
               boolean isRowNum = "rownum".equalsIgnoreCase(twoWhere.getLeft().toString());
               boolean isLess = twoWhere.getOperator() == SQLBinaryOperator.LessThanOrEqual || twoWhere.getOperator() == SQLBinaryOperator.LessThan;
               if (isRowNum && twoWhere.getRight() instanceof SQLIntegerExpr && isLess)
               {
                   int lastrownum = ((SQLIntegerExpr) twoWhere.getRight()).getNumber().intValue();
                   if (operator == SQLBinaryOperator.LessThan&&lastrownum!=0) {
					lastrownum = lastrownum - 1;
				}
                   SQLSelectQuery finalQuery = ((SQLSubqueryTableSource) twoSubSelect.getFrom()).getSelect().getQuery();
                   if (finalQuery instanceof OracleSelectQueryBlock)
                   {
					setLimitIFChange(stmt, rrs, schema, one, firstrownum, lastrownum);
                       parseOrderAggGroupOracle(stmt,rrs, (OracleSelectQueryBlock) finalQuery, schema);
                       isNeedParseOrderAgg=false;
                   }

               }

           }

       }
}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:37,代码来源:DruidSelectOracleParser.java


示例8: statementParse

import com.alibaba.druid.sql.ast.statement.SQLSelectQuery; //导入依赖的package包/类
@Override
public void statementParse(SchemaConfig schema, RouteResultset rrs, SQLStatement stmt) {
	SQLSelectStatement selectStmt = (SQLSelectStatement)stmt;
	SQLSelectQuery sqlSelectQuery = selectStmt.getSelect().getQuery();
	//从mysql解析过来
	if(sqlSelectQuery instanceof MySqlSelectQueryBlock) {
		MySqlSelectQueryBlock mysqlSelectQuery = (MySqlSelectQueryBlock)selectStmt.getSelect().getQuery();
		MySqlSelectQueryBlock.Limit limit=mysqlSelectQuery.getLimit();
		if(limit==null)
		{
               sqlserverParse(schema, rrs);


           }
		if(isNeedParseOrderAgg)
		{
			parseOrderAggGroupMysql(schema, stmt,rrs, mysqlSelectQuery);
			//更改canRunInReadDB属性
			if ((mysqlSelectQuery.isForUpdate() || mysqlSelectQuery.isLockInShareMode()) && rrs.isAutocommit() == false)
			{
				rrs.setCanRunInReadDB(false);
			}
		}

	}


}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:29,代码来源:DruidSelectSqlServerParser.java


示例9: oracleValidationQueryCheck

import com.alibaba.druid.sql.ast.statement.SQLSelectQuery; //导入依赖的package包/类
private void oracleValidationQueryCheck() {
    if (validationQuery == null) {
        return;
    }
    if (validationQuery.length() == 0) {
        return;
    }

    SQLStatementParser sqlStmtParser = SQLParserUtils.createSQLStatementParser(validationQuery, this.dbType);
    List<SQLStatement> stmtList = sqlStmtParser.parseStatementList();

    if (stmtList.size() != 1) {
        return;
    }

    SQLStatement stmt = stmtList.get(0);
    if (!(stmt instanceof SQLSelectStatement)) {
        return;
    }

    SQLSelectQuery query = ((SQLSelectStatement) stmt).getSelect().getQuery();
    if (query instanceof SQLSelectQueryBlock) {
        if (((SQLSelectQueryBlock) query).getFrom() == null) {
            LOG.error("invalid oracle validationQuery. " + validationQuery + ", may should be : " + validationQuery
                    + " FROM DUAL");
        }
    }
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:29,代码来源:ElasticSearchDruidDataSource.java


示例10: db2ValidationQueryCheck

import com.alibaba.druid.sql.ast.statement.SQLSelectQuery; //导入依赖的package包/类
private void db2ValidationQueryCheck() {
    if (validationQuery == null) {
        return;
    }
    if (validationQuery.length() == 0) {
        return;
    }

    SQLStatementParser sqlStmtParser = SQLParserUtils.createSQLStatementParser(validationQuery, this.dbType);
    List<SQLStatement> stmtList = sqlStmtParser.parseStatementList();

    if (stmtList.size() != 1) {
        return;
    }

    SQLStatement stmt = stmtList.get(0);
    if (!(stmt instanceof SQLSelectStatement)) {
        return;
    }

    SQLSelectQuery query = ((SQLSelectStatement) stmt).getSelect().getQuery();
    if (query instanceof SQLSelectQueryBlock) {
        if (((SQLSelectQueryBlock) query).getFrom() == null) {
            LOG.error("invalid db2 validationQuery. " + validationQuery + ", may should be : " + validationQuery
                    + " FROM SYSDUMMY");
        }
    }
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:29,代码来源:ElasticSearchDruidDataSource.java


示例11: endVisit

import com.alibaba.druid.sql.ast.statement.SQLSelectQuery; //导入依赖的package包/类
@Override
public void endVisit(SQLQueryExpr x) {
    SQLSelectQuery sqlSelect = x.getSubQuery().getQuery();
    item = new ItemScalarSubQuery(currentDb, sqlSelect, metaManager);
    initName(x);
    item.setItemName(item.getItemName().replaceAll("\n\\t", " "));
}
 
开发者ID:actiontech,项目名称:dble,代码行数:8,代码来源:MySQLItemVisitor.java


示例12: ItemScalarSubQuery

import com.alibaba.druid.sql.ast.statement.SQLSelectQuery; //导入依赖的package包/类
public ItemScalarSubQuery(String currentDb, SQLSelectQuery query, ProxyMetaManager metaManager) {
    super(currentDb, query, false, metaManager);
    if (this.planNode.getColumnsSelected().size() > 1) {
        throw new MySQLOutPutException(ErrorCode.ER_OPERAND_COLUMNS, "", "Operand should contain 1 column(s)");
    }
    if (!this.correlatedSubQuery) {
        if ((this.planNode.getLimitFrom() == -1)) {
            this.planNode.setLimitFrom(0);
            this.planNode.setLimitTo(2);
        } else if (this.planNode.getLimitTo() > 2) {
            this.planNode.setLimitTo(2);
        }
    }
}
 
开发者ID:actiontech,项目名称:dble,代码行数:15,代码来源:ItemScalarSubQuery.java


示例13: ItemInSubQuery

import com.alibaba.druid.sql.ast.statement.SQLSelectQuery; //导入依赖的package包/类
public ItemInSubQuery(String currentDb, SQLSelectQuery query, Item leftOperand, boolean isNeg, ProxyMetaManager metaManager) {
    super(currentDb, query, metaManager);
    this.leftOperand = leftOperand;
    this.isNeg = isNeg;
    if (this.planNode.getColumnsSelected().size() > 1) {
        throw new MySQLOutPutException(ErrorCode.ER_OPERAND_COLUMNS, "", "Operand should contain 1 column(s)");
    }
    this.select = this.planNode.getColumnsSelected().get(0);
}
 
开发者ID:actiontech,项目名称:dble,代码行数:10,代码来源:ItemInSubQuery.java


示例14: ItemAllAnySubQuery

import com.alibaba.druid.sql.ast.statement.SQLSelectQuery; //导入依赖的package包/类
public ItemAllAnySubQuery(String currentDb, SQLSelectQuery query, SQLBinaryOperator operator, boolean isAll, ProxyMetaManager metaManager) {
    super(currentDb, query, metaManager);
    this.isAll = isAll;
    this.operator = operator;
    if (this.planNode.getColumnsSelected().size() > 1) {
        throw new MySQLOutPutException(ErrorCode.ER_OPERAND_COLUMNS, "", "Operand should contain 1 column(s)");
    }
    this.select = this.planNode.getColumnsSelected().get(0);
}
 
开发者ID:actiontech,项目名称:dble,代码行数:10,代码来源:ItemAllAnySubQuery.java


示例15: ItemExistsSubQuery

import com.alibaba.druid.sql.ast.statement.SQLSelectQuery; //导入依赖的package包/类
public ItemExistsSubQuery(String currentDb, SQLSelectQuery query, boolean isNot, ProxyMetaManager metaManager) {
    super(currentDb, query, false, metaManager);
    this.isNot = isNot;
    if (!this.correlatedSubQuery) {
        if ((this.planNode.getLimitFrom() == -1)) {
            this.planNode.setLimitFrom(0);
            this.planNode.setLimitTo(1);
        } else if (this.planNode.getLimitTo() > 1) {
            this.planNode.setLimitTo(1);
        }
        this.select = new ItemInt(1L);
        this.planNode.getColumnsSelected().add(select);
    }
}
 
开发者ID:actiontech,项目名称:dble,代码行数:15,代码来源:ItemExistsSubQuery.java


示例16: parseStatement

import com.alibaba.druid.sql.ast.statement.SQLSelectQuery; //导入依赖的package包/类
protected void parseStatement(ParseResult result, ExecutePlan plan, SQLSelectStatement statement){
     // 单库单表
     if (plan.getSqlList().size() <= 1){
         return;
     }

     SQLSelectQuery sqlSelectQuery = statement.getSelect().getQuery();
     if(sqlSelectQuery instanceof MySqlSelectQueryBlock) {
         // mysql查询
         parseMysqlQueary(result, plan, (MySqlSelectQueryBlock) sqlSelectQuery);
     } else if (sqlSelectQuery instanceof MySqlUnionQuery) {
         throw new BayMaxException("Union暂不支持发送到多库多表上执行,只能在单库单表执行!");
         // TODO 测试
/*
MySqlUnionQuery unionQuery = (MySqlUnionQuery)sqlSelectQuery;
         SQLSelectQuery left = unionQuery.getLeft();
         SQLSelectQuery right = unionQuery.getLeft();
         if (left instanceof MySqlSelectQueryBlock){
             parseMysqlQueary(result, plan, (MySqlSelectQueryBlock) left);
         }
         if (right instanceof MySqlSelectQueryBlock){
             parseMysqlQueary(result, plan, (MySqlSelectQueryBlock) right);
         }
         */
         //if (left.getFrom().getAlias().equalsIgnoreCase(plan.getSqlList().get(0).getLogicTableName())){

         //}
     }
 }
 
开发者ID:tongbanjie,项目名称:baymax,代码行数:30,代码来源:MySqlSelectParser.java


示例17: ItemSubQuery

import com.alibaba.druid.sql.ast.statement.SQLSelectQuery; //导入依赖的package包/类
public ItemSubQuery(String currentDb, SQLSelectQuery query, ProxyMetaManager metaManager) {
    this.query = query;
    this.currentDb = currentDb;
    this.metaManager = metaManager;
    init();
}
 
开发者ID:actiontech,项目名称:dble,代码行数:7,代码来源:ItemSubQuery.java


示例18: ItemSingleRowSubQuery

import com.alibaba.druid.sql.ast.statement.SQLSelectQuery; //导入依赖的package包/类
public ItemSingleRowSubQuery(String currentDb, SQLSelectQuery query, boolean isField, ProxyMetaManager metaManager) {
    super(currentDb, query, metaManager);
    this.select = this.planNode.getColumnsSelected().get(0);
    this.isField = isField;
}
 
开发者ID:actiontech,项目名称:dble,代码行数:6,代码来源:ItemSingleRowSubQuery.java


示例19: ItemMultiRowSubQuery

import com.alibaba.druid.sql.ast.statement.SQLSelectQuery; //导入依赖的package包/类
/**
 * @param currentDb
 * @param query
 */
public ItemMultiRowSubQuery(String currentDb, SQLSelectQuery query, ProxyMetaManager metaManager) {
    super(currentDb, query, metaManager);
}
 
开发者ID:actiontech,项目名称:dble,代码行数:8,代码来源:ItemMultiRowSubQuery.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BitmapEncoder类代码示例发布时间:2022-05-23
下一篇:
Java TLongObjectHashMap类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap