use of com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock in project druid by alibaba.
the class DruidDataSource method oracleValidationQueryCheck.
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");
}
}
}
use of com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock in project druid by alibaba.
the class DruidDataSource method db2ValidationQueryCheck.
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");
}
}
}
use of com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock in project druid by alibaba.
the class SQLASTVisitorAdapterTest method test_adapter.
public void test_adapter() throws Exception {
SQLASTVisitorAdapter adapter = new SQLASTVisitorAdapter();
new SQLBinaryOpExpr().accept(adapter);
new SQLInListExpr().accept(adapter);
new SQLSelectQueryBlock().accept(adapter);
new SQLDropTableStatement().accept(adapter);
new SQLCreateTableStatement().accept(adapter);
new SQLDeleteStatement().accept(adapter);
new SQLCurrentOfCursorExpr().accept(adapter);
new SQLInsertStatement().accept(adapter);
new SQLUpdateStatement().accept(adapter);
new SQLNotNullConstraint().accept(adapter);
new SQLMethodInvokeExpr().accept(adapter);
new SQLCallStatement().accept(adapter);
new SQLSomeExpr().accept(adapter);
new SQLAnyExpr().accept(adapter);
new SQLAllExpr().accept(adapter);
new SQLDefaultExpr().accept(adapter);
new SQLCommentStatement().accept(adapter);
new SQLDropViewStatement().accept(adapter);
new SQLSavePointStatement().accept(adapter);
new SQLReleaseSavePointStatement().accept(adapter);
new SQLCreateDatabaseStatement().accept(adapter);
new SQLAlterTableDropIndex().accept(adapter);
new SQLOver().accept(adapter);
new SQLWithSubqueryClause().accept(adapter);
new SQLAlterTableAlterColumn().accept(adapter);
new SQLAlterTableStatement().accept(adapter);
new SQLAlterTableDisableConstraint().accept(adapter);
new SQLAlterTableEnableConstraint().accept(adapter);
new SQLColumnCheck().accept(adapter);
new SQLExprHint().accept(adapter);
new SQLAlterTableDropConstraint().accept(adapter);
}
Aggregations