mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
fix sonar rule check violations
This commit is contained in:
@@ -633,7 +633,7 @@ public class MultiDataSourceConnection extends WrapperAdapter implements Connect
|
||||
public boolean isWrapperFor(Class<?> iface) throws SQLException {
|
||||
boolean result = super.isWrapperFor(iface);
|
||||
|
||||
if (result == false && conn != null) {
|
||||
if ((!result) && conn != null) {
|
||||
result = conn.isWrapperFor(iface);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,10 +31,10 @@ public class CobarDataSource extends MultiDataSource {
|
||||
|
||||
private final static Log LOG = LogFactory.getLog(CobarDataSource.class);
|
||||
|
||||
public static long DEFAULT_FAILURE_DETECT_PERRIOD_MILLIS = 1000 * 3; // 3
|
||||
// seconds
|
||||
public static long DEFAULT_CONFIG_LOAD_PERRIOD_MILLIS = 1000 * 60 * 3; // 3
|
||||
// minutes
|
||||
public final static long DEFAULT_FAILURE_DETECT_PERRIOD_MILLIS = 1000 * 3; // 3
|
||||
// seconds
|
||||
public final static long DEFAULT_CONFIG_LOAD_PERRIOD_MILLIS = 1000 * 60 * 3; // 3
|
||||
// minutes
|
||||
|
||||
private String url;
|
||||
|
||||
@@ -50,7 +50,6 @@ public class CobarDataSource extends MultiDataSource {
|
||||
private List<Filter> proxyFilters = new ArrayList<Filter>();
|
||||
private String filters;
|
||||
|
||||
|
||||
public CobarDataSource(){
|
||||
this.setFailureDetector(new CobarFailureDetecter());
|
||||
this.setFailureDetectPeriodMillis(DEFAULT_FAILURE_DETECT_PERRIOD_MILLIS);
|
||||
@@ -122,7 +121,7 @@ public class CobarDataSource extends MultiDataSource {
|
||||
if (this.getConfigLoader() == null) {
|
||||
this.setConfigLoader(new CobarConfigLoader(this));
|
||||
}
|
||||
|
||||
|
||||
final int RETRY_COUNT = 3;
|
||||
for (int i = 0; i < RETRY_COUNT; ++i) {
|
||||
try {
|
||||
|
||||
@@ -16,12 +16,11 @@
|
||||
package com.alibaba.druid.sql.dialect.hive.parser;
|
||||
|
||||
import com.alibaba.druid.sql.parser.Lexer;
|
||||
import com.alibaba.druid.sql.parser.ParserException;
|
||||
import com.alibaba.druid.sql.parser.SQLExprParser;
|
||||
|
||||
|
||||
public class HiveExprParser extends SQLExprParser {
|
||||
public HiveExprParser(String sql) throws ParserException{
|
||||
public HiveExprParser(String sql) {
|
||||
super(new HiveLexer(sql));
|
||||
this.lexer.nextToken();
|
||||
}
|
||||
|
||||
+4
-4
@@ -32,7 +32,7 @@ import com.alibaba.druid.sql.parser.Token;
|
||||
|
||||
public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
|
||||
public MySqlCreateTableParser(String sql) throws ParserException{
|
||||
public MySqlCreateTableParser(String sql) {
|
||||
super(new MySqlExprParser(sql));
|
||||
}
|
||||
|
||||
@@ -40,11 +40,11 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
super(exprParser);
|
||||
}
|
||||
|
||||
public SQLCreateTableStatement parseCrateTable() throws ParserException {
|
||||
public SQLCreateTableStatement parseCrateTable() {
|
||||
return parseCrateTable(true);
|
||||
}
|
||||
|
||||
public MySqlCreateTableStatement parseCrateTable(boolean acceptCreate) throws ParserException {
|
||||
public MySqlCreateTableStatement parseCrateTable(boolean acceptCreate) {
|
||||
if (acceptCreate) {
|
||||
accept(Token.CREATE);
|
||||
}
|
||||
@@ -182,7 +182,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
protected SQLTableConstaint parseConstraint() throws ParserException {
|
||||
protected SQLTableConstaint parseConstraint() {
|
||||
SQLName name = null;
|
||||
if (lexer.token() == (Token.CONSTRAINT)) {
|
||||
lexer.nextToken();
|
||||
|
||||
@@ -52,12 +52,12 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
super(lexer);
|
||||
}
|
||||
|
||||
public MySqlExprParser(String sql) throws ParserException{
|
||||
public MySqlExprParser(String sql) {
|
||||
this(new MySqlLexer(sql));
|
||||
this.lexer.nextToken();
|
||||
}
|
||||
|
||||
public SQLExpr relationalRest(SQLExpr expr) throws ParserException {
|
||||
public SQLExpr relationalRest(SQLExpr expr) {
|
||||
if (identifierEquals("REGEXP")) {
|
||||
lexer.nextToken();
|
||||
SQLExpr rightExp = equality();
|
||||
@@ -79,7 +79,7 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
return super.relationalRest(expr);
|
||||
}
|
||||
|
||||
public SQLExpr multiplicativeRest(SQLExpr expr) throws ParserException {
|
||||
public SQLExpr multiplicativeRest(SQLExpr expr) {
|
||||
if (lexer.token() == Token.IDENTIFIER && "MOD".equalsIgnoreCase(lexer.stringVal())) {
|
||||
lexer.nextToken();
|
||||
SQLExpr rightExp = primary();
|
||||
@@ -114,7 +114,7 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
return super.notRationalRest(expr);
|
||||
}
|
||||
|
||||
public SQLExpr primary() throws ParserException {
|
||||
public SQLExpr primary() {
|
||||
final Token tok = lexer.token();
|
||||
|
||||
if (identifierEquals("outfile")) {
|
||||
@@ -158,7 +158,7 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
|
||||
}
|
||||
|
||||
public final SQLExpr primaryRest(SQLExpr expr) throws ParserException {
|
||||
public final SQLExpr primaryRest(SQLExpr expr) {
|
||||
if (expr == null) {
|
||||
throw new IllegalArgumentException("expr");
|
||||
}
|
||||
@@ -489,7 +489,7 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
}
|
||||
}
|
||||
|
||||
public SQLColumnDefinition parseColumn() throws ParserException {
|
||||
public SQLColumnDefinition parseColumn() {
|
||||
MySqlSQLColumnDefinition column = new MySqlSQLColumnDefinition();
|
||||
column.setName(name());
|
||||
column.setDataType(parseDataType());
|
||||
@@ -497,7 +497,7 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
return parseColumnRest(column);
|
||||
}
|
||||
|
||||
public SQLColumnDefinition parseColumnRest(SQLColumnDefinition column) throws ParserException {
|
||||
public SQLColumnDefinition parseColumnRest(SQLColumnDefinition column) {
|
||||
if (identifierEquals("AUTO_INCREMENT")) {
|
||||
lexer.nextToken();
|
||||
if (column instanceof MySqlSQLColumnDefinition) {
|
||||
@@ -514,7 +514,7 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
return column;
|
||||
}
|
||||
|
||||
public SQLExpr orRest(SQLExpr expr) throws ParserException {
|
||||
public SQLExpr orRest(SQLExpr expr) {
|
||||
|
||||
for (;;) {
|
||||
if (lexer.token() == Token.OR || lexer.token() == Token.BARBAR) {
|
||||
@@ -566,7 +566,7 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
return item;
|
||||
}
|
||||
|
||||
public SQLName nameRest(SQLName name) throws ParserException {
|
||||
public SQLName nameRest(SQLName name) {
|
||||
if (lexer.token() == Token.VARIANT && "@".equals(lexer.stringVal())) {
|
||||
lexer.nextToken();
|
||||
MySqlUserName userName = new MySqlUserName();
|
||||
|
||||
@@ -44,12 +44,12 @@ public class MySqlSelectParser extends SQLSelectParser {
|
||||
super(exprParser);
|
||||
}
|
||||
|
||||
public MySqlSelectParser(String sql) throws ParserException{
|
||||
public MySqlSelectParser(String sql) {
|
||||
this(new MySqlExprParser(sql));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SQLSelectQuery query() throws ParserException {
|
||||
public SQLSelectQuery query() {
|
||||
if (lexer.token() == (Token.LPAREN)) {
|
||||
lexer.nextToken();
|
||||
|
||||
@@ -220,7 +220,7 @@ public class MySqlSelectParser extends SQLSelectParser {
|
||||
return queryRest(queryBlock);
|
||||
}
|
||||
|
||||
protected void parseGroupBy(SQLSelectQueryBlock queryBlock) throws ParserException {
|
||||
protected void parseGroupBy(SQLSelectQueryBlock queryBlock) {
|
||||
if (lexer.token() == (Token.GROUP)) {
|
||||
lexer.nextToken();
|
||||
accept(Token.BY);
|
||||
@@ -255,7 +255,7 @@ public class MySqlSelectParser extends SQLSelectParser {
|
||||
}
|
||||
}
|
||||
|
||||
protected SQLTableSource parseTableSourceRest(SQLTableSource tableSource) throws ParserException {
|
||||
protected SQLTableSource parseTableSourceRest(SQLTableSource tableSource) {
|
||||
if (identifierEquals("USING")) {
|
||||
return tableSource;
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
private static final String DELAYED = "DELAYED";
|
||||
private static final String LOW_PRIORITY = "LOW_PRIORITY";
|
||||
|
||||
public MySqlStatementParser(String sql) throws ParserException{
|
||||
public MySqlStatementParser(String sql) {
|
||||
super(new MySqlExprParser(sql));
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ public class OracleExprParser extends SQLExprParser {
|
||||
this.lexer.nextToken();
|
||||
}
|
||||
|
||||
public SQLDataType parseDataType() throws ParserException {
|
||||
public SQLDataType parseDataType() {
|
||||
|
||||
if (lexer.token() == Token.DEFAULT || lexer.token() == Token.NOT || lexer.token() == Token.NULL) {
|
||||
return null;
|
||||
@@ -127,7 +127,7 @@ public class OracleExprParser extends SQLExprParser {
|
||||
return false;
|
||||
}
|
||||
|
||||
public SQLExpr primary() throws ParserException {
|
||||
public SQLExpr primary() {
|
||||
final Token tok = lexer.token();
|
||||
|
||||
SQLExpr sqlExpr = null;
|
||||
@@ -302,7 +302,7 @@ public class OracleExprParser extends SQLExprParser {
|
||||
return super.methodRest(expr, false);
|
||||
}
|
||||
|
||||
public SQLExpr primaryRest(SQLExpr expr) throws ParserException {
|
||||
public SQLExpr primaryRest(SQLExpr expr) {
|
||||
if (lexer.token() == Token.IDENTIFIER && expr instanceof SQLNumericLiteralExpr) {
|
||||
String ident = lexer.stringVal();
|
||||
if (ident.length() == 1) {
|
||||
@@ -729,7 +729,7 @@ public class OracleExprParser extends SQLExprParser {
|
||||
return interval;
|
||||
}
|
||||
|
||||
public SQLExpr relationalRest(SQLExpr expr) throws ParserException {
|
||||
public SQLExpr relationalRest(SQLExpr expr) {
|
||||
if (lexer.token() == Token.IS) {
|
||||
lexer.nextToken();
|
||||
|
||||
@@ -752,7 +752,7 @@ public class OracleExprParser extends SQLExprParser {
|
||||
}
|
||||
|
||||
|
||||
public SQLName name() throws ParserException {
|
||||
public SQLName name() {
|
||||
SQLName name = super.name();
|
||||
|
||||
if (lexer.token() == Token.MONKEYS_AT) {
|
||||
@@ -770,7 +770,7 @@ public class OracleExprParser extends SQLExprParser {
|
||||
return name;
|
||||
}
|
||||
|
||||
public SQLExpr equalityRest(SQLExpr expr) throws ParserException {
|
||||
public SQLExpr equalityRest(SQLExpr expr) {
|
||||
SQLExpr rightExp;
|
||||
if (lexer.token() == Token.EQ) {
|
||||
lexer.nextToken();
|
||||
@@ -828,7 +828,7 @@ public class OracleExprParser extends SQLExprParser {
|
||||
return column;
|
||||
}
|
||||
|
||||
public SQLExpr exprRest(SQLExpr expr) throws ParserException {
|
||||
public SQLExpr exprRest(SQLExpr expr) {
|
||||
expr = super.exprRest(expr);
|
||||
|
||||
if (lexer.token() == Token.COLONEQ) {
|
||||
|
||||
@@ -620,7 +620,7 @@ public class OracleSelectParser extends SQLSelectParser {
|
||||
}
|
||||
}
|
||||
|
||||
protected String as() throws ParserException {
|
||||
protected String as() {
|
||||
if (lexer.token() == Token.CONNECT) {
|
||||
return null;
|
||||
}
|
||||
|
||||
+5
-5
@@ -130,11 +130,11 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseStatementList(List<SQLStatement> statementList) throws ParserException {
|
||||
public void parseStatementList(List<SQLStatement> statementList) {
|
||||
parseStatementList(statementList, -1);
|
||||
}
|
||||
|
||||
public void parseStatementList(List<SQLStatement> statementList, int max) throws ParserException {
|
||||
public void parseStatementList(List<SQLStatement> statementList, int max) {
|
||||
for (;;) {
|
||||
if (max != -1) {
|
||||
if (statementList.size() >= max) {
|
||||
@@ -1106,7 +1106,7 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
return new OracleSelectParser(this.exprParser);
|
||||
}
|
||||
|
||||
public OracleMergeStatement parseMerge() throws ParserException {
|
||||
public OracleMergeStatement parseMerge() {
|
||||
accept(Token.MERGE);
|
||||
|
||||
OracleMergeStatement stmt = new OracleMergeStatement();
|
||||
@@ -1410,7 +1410,7 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
return stmt;
|
||||
}
|
||||
|
||||
public OracleDeleteStatement parseDeleteStatement() throws ParserException {
|
||||
public OracleDeleteStatement parseDeleteStatement() {
|
||||
OracleDeleteStatement deleteStatement = new OracleDeleteStatement();
|
||||
|
||||
if (lexer.token() == Token.DELETE) {
|
||||
@@ -1595,7 +1595,7 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
return stmt;
|
||||
}
|
||||
|
||||
public SQLUpdateStatement parseUpdateStatement() throws ParserException {
|
||||
public SQLUpdateStatement parseUpdateStatement() {
|
||||
return new OracleUpdateParser(this.lexer).parseUpdateStatement();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import com.alibaba.druid.sql.parser.Token;
|
||||
|
||||
public class OracleUpdateParser extends SQLStatementParser {
|
||||
|
||||
public OracleUpdateParser(String sql) throws ParserException{
|
||||
public OracleUpdateParser(String sql) {
|
||||
super(new OracleExprParser(sql));
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class OracleUpdateParser extends SQLStatementParser {
|
||||
super(new OracleExprParser(lexer));
|
||||
}
|
||||
|
||||
public OracleUpdateStatement parseUpdateStatement() throws ParserException {
|
||||
public OracleUpdateStatement parseUpdateStatement() {
|
||||
OracleUpdateStatement update = new OracleUpdateStatement();
|
||||
|
||||
if (lexer.token() == Token.UPDATE) {
|
||||
@@ -66,13 +66,13 @@ public class OracleUpdateParser extends SQLStatementParser {
|
||||
return update;
|
||||
}
|
||||
|
||||
private void parseErrorLoging(OracleUpdateStatement update) throws ParserException {
|
||||
private void parseErrorLoging(OracleUpdateStatement update) {
|
||||
if (identifierEquals("LOG")) {
|
||||
throw new ParserException("TODO");
|
||||
}
|
||||
}
|
||||
|
||||
private void parseReturn(OracleUpdateStatement update) throws ParserException {
|
||||
private void parseReturn(OracleUpdateStatement update) {
|
||||
if (identifierEquals("RETURN") || lexer.token() == Token.RETURNING) {
|
||||
lexer.nextToken();
|
||||
|
||||
@@ -104,20 +104,20 @@ public class OracleUpdateParser extends SQLStatementParser {
|
||||
}
|
||||
}
|
||||
|
||||
private void parseHints(OracleUpdateStatement update) throws ParserException {
|
||||
private void parseHints(OracleUpdateStatement update) {
|
||||
if (lexer.token() == Token.HINT) {
|
||||
throw new ParserException("TODO");
|
||||
}
|
||||
}
|
||||
|
||||
private void parseWhere(OracleUpdateStatement update) throws ParserException {
|
||||
private void parseWhere(OracleUpdateStatement update) {
|
||||
if (lexer.token() == (Token.WHERE)) {
|
||||
lexer.nextToken();
|
||||
update.setWhere(this.exprParser.expr());
|
||||
}
|
||||
}
|
||||
|
||||
private void parseSet(OracleUpdateStatement update) throws ParserException {
|
||||
private void parseSet(OracleUpdateStatement update) {
|
||||
accept(Token.SET);
|
||||
|
||||
for (;;) {
|
||||
|
||||
@@ -20,12 +20,11 @@ import com.alibaba.druid.sql.dialect.postgresql.ast.PGAggregateExpr;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.PGOrderBy;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGAnalytic;
|
||||
import com.alibaba.druid.sql.parser.Lexer;
|
||||
import com.alibaba.druid.sql.parser.ParserException;
|
||||
import com.alibaba.druid.sql.parser.SQLExprParser;
|
||||
import com.alibaba.druid.sql.parser.Token;
|
||||
|
||||
public class PGExprParser extends SQLExprParser{
|
||||
public PGExprParser(String sql) throws ParserException{
|
||||
public PGExprParser(String sql) {
|
||||
super(new PGLexer(sql));
|
||||
this.lexer.nextToken();
|
||||
}
|
||||
@@ -34,7 +33,7 @@ public class PGExprParser extends SQLExprParser{
|
||||
super(lexer);
|
||||
}
|
||||
|
||||
protected SQLAggregateExpr parseAggregateExpr(String methodName) throws ParserException {
|
||||
protected SQLAggregateExpr parseAggregateExpr(String methodName) {
|
||||
methodName = methodName.toUpperCase();
|
||||
|
||||
PGAggregateExpr aggregateExpr;
|
||||
|
||||
+4
-4
@@ -40,7 +40,7 @@ import com.alibaba.druid.sql.parser.Token;
|
||||
|
||||
public class PGSQLStatementParser extends SQLStatementParser {
|
||||
|
||||
public PGSQLStatementParser(String sql) throws ParserException{
|
||||
public PGSQLStatementParser(String sql) {
|
||||
super (new PGExprParser(sql));
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class PGSQLStatementParser extends SQLStatementParser {
|
||||
return new PGSelectParser(this.exprParser);
|
||||
}
|
||||
|
||||
public SQLUpdateStatement parseUpdateStatement() throws ParserException {
|
||||
public SQLUpdateStatement parseUpdateStatement() {
|
||||
accept(Token.UPDATE);
|
||||
|
||||
PGUpdateStatement udpateStatement = new PGUpdateStatement();
|
||||
@@ -150,7 +150,7 @@ public class PGSQLStatementParser extends SQLStatementParser {
|
||||
return stmt;
|
||||
}
|
||||
|
||||
public PGDeleteStatement parseDeleteStatement() throws ParserException {
|
||||
public PGDeleteStatement parseDeleteStatement() {
|
||||
lexer.nextToken();
|
||||
PGDeleteStatement deleteStatement = new PGDeleteStatement();
|
||||
|
||||
@@ -329,7 +329,7 @@ public class PGSQLStatementParser extends SQLStatementParser {
|
||||
return withQuery;
|
||||
}
|
||||
|
||||
public PGSelectStatement parseSelect() throws ParserException {
|
||||
public PGSelectStatement parseSelect() {
|
||||
return new PGSelectStatement(createSQLSelectParser().select());
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public class PGSelectParser extends SQLSelectParser {
|
||||
super(exprParser);
|
||||
}
|
||||
|
||||
public PGSelectParser(String sql) throws ParserException{
|
||||
public PGSelectParser(String sql) {
|
||||
this(new PGExprParser(sql));
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class PGSelectParser extends SQLSelectParser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SQLSelectQuery query() throws ParserException {
|
||||
public SQLSelectQuery query() {
|
||||
PGSelectQueryBlock queryBlock = new PGSelectQueryBlock();
|
||||
|
||||
if (lexer.token() == Token.SELECT) {
|
||||
@@ -219,7 +219,7 @@ public class PGSelectParser extends SQLSelectParser {
|
||||
return queryRest(queryBlock);
|
||||
}
|
||||
|
||||
protected SQLTableSource parseTableSourceRest(SQLTableSource tableSource) throws ParserException {
|
||||
protected SQLTableSource parseTableSourceRest(SQLTableSource tableSource) {
|
||||
if (lexer.token() == Token.AS && tableSource instanceof SQLExprTableSource) {
|
||||
String alias = this.as();
|
||||
|
||||
|
||||
+3
-4
@@ -20,7 +20,6 @@ import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLPropertyExpr;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.expr.SQLServerObjectReferenceExpr;
|
||||
import com.alibaba.druid.sql.parser.Lexer;
|
||||
import com.alibaba.druid.sql.parser.ParserException;
|
||||
import com.alibaba.druid.sql.parser.SQLExprParser;
|
||||
import com.alibaba.druid.sql.parser.Token;
|
||||
|
||||
@@ -30,12 +29,12 @@ public class SQLServerExprParser extends SQLExprParser {
|
||||
super(lexer);
|
||||
}
|
||||
|
||||
public SQLServerExprParser(String sql) throws ParserException{
|
||||
public SQLServerExprParser(String sql) {
|
||||
super(new SQLServerLexer(sql));
|
||||
this.lexer.nextToken();
|
||||
}
|
||||
|
||||
public SQLExpr primaryRest(SQLExpr expr) throws ParserException {
|
||||
public SQLExpr primaryRest(SQLExpr expr) {
|
||||
if (lexer.token() == Token.DOTDOT) {
|
||||
expr = nameRest((SQLName) expr);
|
||||
}
|
||||
@@ -43,7 +42,7 @@ public class SQLServerExprParser extends SQLExprParser {
|
||||
return super.primaryRest(expr);
|
||||
}
|
||||
|
||||
public SQLName nameRest(SQLName expr) throws ParserException {
|
||||
public SQLName nameRest(SQLName expr) {
|
||||
if (lexer.token() == Token.DOTDOT) {
|
||||
lexer.nextToken();
|
||||
String text = lexer.stringVal();
|
||||
|
||||
+2
-3
@@ -21,7 +21,6 @@ import com.alibaba.druid.sql.ast.statement.SQLSelectQuery;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.SQLServerSelect;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.SQLServerSelectQueryBlock;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.Top;
|
||||
import com.alibaba.druid.sql.parser.ParserException;
|
||||
import com.alibaba.druid.sql.parser.SQLExprParser;
|
||||
import com.alibaba.druid.sql.parser.SQLSelectParser;
|
||||
import com.alibaba.druid.sql.parser.Token;
|
||||
@@ -36,7 +35,7 @@ public class SQLServerSelectParser extends SQLSelectParser {
|
||||
super(exprParser);
|
||||
}
|
||||
|
||||
public SQLSelect select() throws ParserException {
|
||||
public SQLSelect select() {
|
||||
SQLServerSelect select = new SQLServerSelect();
|
||||
|
||||
select.setQuery(query());
|
||||
@@ -49,7 +48,7 @@ public class SQLServerSelectParser extends SQLSelectParser {
|
||||
return select;
|
||||
}
|
||||
|
||||
public SQLSelectQuery query() throws ParserException {
|
||||
public SQLSelectQuery query() {
|
||||
if (lexer.token() == Token.LPAREN) {
|
||||
lexer.nextToken();
|
||||
|
||||
|
||||
@@ -178,12 +178,6 @@ public class Lexer {
|
||||
token = ERROR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Report an error at the current token position using the provided arguments.
|
||||
*/
|
||||
private void lexError(String key, Object... args) {
|
||||
lexError(tokenPos, key, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current token, set by nextToken().
|
||||
@@ -376,7 +370,7 @@ public class Lexer {
|
||||
token = EOF;
|
||||
tokenPos = bp = eofPos;
|
||||
} else {
|
||||
lexError("illegal.char", String.valueOf((int) ch));
|
||||
lexError(tokenPos, "illegal.char", String.valueOf((int) ch));
|
||||
scanChar();
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public class SQLParser {
|
||||
}
|
||||
}
|
||||
|
||||
protected String as() throws ParserException {
|
||||
protected String as() {
|
||||
String alias = null;
|
||||
|
||||
if (lexer.token() == Token.AS) {
|
||||
|
||||
@@ -46,7 +46,7 @@ public class SQLSelectParser extends SQLParser {
|
||||
this.exprParser = exprParser;
|
||||
}
|
||||
|
||||
public SQLSelect select() throws ParserException {
|
||||
public SQLSelect select() {
|
||||
SQLSelect select = new SQLSelect();
|
||||
|
||||
select.setQuery(query());
|
||||
@@ -72,7 +72,7 @@ public class SQLSelectParser extends SQLParser {
|
||||
return union;
|
||||
}
|
||||
|
||||
public SQLSelectQuery queryRest(SQLSelectQuery selectQuery) throws ParserException {
|
||||
public SQLSelectQuery queryRest(SQLSelectQuery selectQuery) {
|
||||
if (lexer.token() == Token.UNION) {
|
||||
lexer.nextToken();
|
||||
|
||||
@@ -123,7 +123,7 @@ public class SQLSelectParser extends SQLParser {
|
||||
return selectQuery;
|
||||
}
|
||||
|
||||
public SQLSelectQuery query() throws ParserException {
|
||||
public SQLSelectQuery query() {
|
||||
if (lexer.token() == Token.LPAREN) {
|
||||
lexer.nextToken();
|
||||
|
||||
@@ -159,7 +159,7 @@ public class SQLSelectParser extends SQLParser {
|
||||
return queryRest(queryBlock);
|
||||
}
|
||||
|
||||
protected void parseWhere(SQLSelectQueryBlock queryBlock) throws ParserException {
|
||||
protected void parseWhere(SQLSelectQueryBlock queryBlock) {
|
||||
if (lexer.token() == Token.WHERE) {
|
||||
lexer.nextToken();
|
||||
|
||||
@@ -167,7 +167,7 @@ public class SQLSelectParser extends SQLParser {
|
||||
}
|
||||
}
|
||||
|
||||
protected void parseGroupBy(SQLSelectQueryBlock queryBlock) throws ParserException {
|
||||
protected void parseGroupBy(SQLSelectQueryBlock queryBlock) {
|
||||
if (lexer.token() == Token.GROUP) {
|
||||
lexer.nextToken();
|
||||
accept(Token.BY);
|
||||
@@ -198,7 +198,7 @@ public class SQLSelectParser extends SQLParser {
|
||||
}
|
||||
}
|
||||
|
||||
protected void parseSelectList(SQLSelectQueryBlock queryBlock) throws ParserException {
|
||||
protected void parseSelectList(SQLSelectQueryBlock queryBlock) {
|
||||
queryBlock.getSelectList().add(new SQLSelectItem(expr(), as()));
|
||||
|
||||
while (lexer.token() == Token.COMMA) {
|
||||
@@ -207,7 +207,7 @@ public class SQLSelectParser extends SQLParser {
|
||||
}
|
||||
}
|
||||
|
||||
public void parseFrom(SQLSelectQueryBlock queryBlock) throws ParserException {
|
||||
public void parseFrom(SQLSelectQueryBlock queryBlock) {
|
||||
if (lexer.token() != Token.FROM) {
|
||||
return;
|
||||
}
|
||||
@@ -217,7 +217,7 @@ public class SQLSelectParser extends SQLParser {
|
||||
queryBlock.setFrom(parseTableSource());
|
||||
}
|
||||
|
||||
public SQLTableSource parseTableSource() throws ParserException {
|
||||
public SQLTableSource parseTableSource() {
|
||||
if (lexer.token() == Token.LPAREN) {
|
||||
lexer.nextToken();
|
||||
SQLTableSource tableSource;
|
||||
@@ -248,7 +248,7 @@ public class SQLSelectParser extends SQLParser {
|
||||
return parseTableSourceRest(tableReference);
|
||||
}
|
||||
|
||||
private void parseTableSourceQueryTableExpr(SQLExprTableSource tableReference) throws ParserException {
|
||||
private void parseTableSourceQueryTableExpr(SQLExprTableSource tableReference) {
|
||||
if (lexer.token() == Token.LITERAL_ALIAS || lexer.token() == Token.IDENTIFIED
|
||||
|| lexer.token() == Token.LITERAL_CHARS) {
|
||||
tableReference.setExpr(this.exprParser.name());
|
||||
@@ -258,7 +258,7 @@ public class SQLSelectParser extends SQLParser {
|
||||
tableReference.setExpr(expr());
|
||||
}
|
||||
|
||||
protected SQLTableSource parseTableSourceRest(SQLTableSource tableSource) throws ParserException {
|
||||
protected SQLTableSource parseTableSourceRest(SQLTableSource tableSource) {
|
||||
if ((tableSource.getAlias() == null) || (tableSource.getAlias().length() == 0)) {
|
||||
if (lexer.token() != Token.LEFT && lexer.token() != Token.RIGHT && lexer.token() != Token.FULL) {
|
||||
String alias = as();
|
||||
@@ -329,7 +329,7 @@ public class SQLSelectParser extends SQLParser {
|
||||
return this.exprParser.expr();
|
||||
}
|
||||
|
||||
public SQLOrderBy parseOrderBy() throws ParserException {
|
||||
public SQLOrderBy parseOrderBy() {
|
||||
return this.exprParser.parseOrderBy();
|
||||
}
|
||||
|
||||
|
||||
@@ -63,13 +63,13 @@ public class SQLStatementParser extends SQLParser {
|
||||
return exprParser;
|
||||
}
|
||||
|
||||
public List<SQLStatement> parseStatementList() throws ParserException {
|
||||
public List<SQLStatement> parseStatementList() {
|
||||
List<SQLStatement> statementList = new ArrayList<SQLStatement>();
|
||||
parseStatementList(statementList);
|
||||
return statementList;
|
||||
}
|
||||
|
||||
public void parseStatementList(List<SQLStatement> statementList) throws ParserException {
|
||||
public void parseStatementList(List<SQLStatement> statementList) {
|
||||
for (;;) {
|
||||
if (lexer.token() == Token.EOF) {
|
||||
return;
|
||||
@@ -408,11 +408,11 @@ public class SQLStatementParser extends SQLParser {
|
||||
return false;
|
||||
}
|
||||
|
||||
public SQLStatement parseDropUser() throws ParserException {
|
||||
public SQLStatement parseDropUser() {
|
||||
throw new ParserException("TODO " + lexer.token());
|
||||
}
|
||||
|
||||
public SQLStatement parseDropIndex() throws ParserException {
|
||||
public SQLStatement parseDropIndex() {
|
||||
accept(Token.INDEX);
|
||||
SQLDropIndexStatement stmt = new SQLDropIndexStatement();
|
||||
stmt.setIndexName(this.exprParser.name());
|
||||
@@ -421,7 +421,7 @@ public class SQLStatementParser extends SQLParser {
|
||||
return stmt;
|
||||
}
|
||||
|
||||
public SQLCallStatement parseCall() throws ParserException {
|
||||
public SQLCallStatement parseCall() {
|
||||
|
||||
boolean brace = false;
|
||||
if (lexer.token() == Token.LBRACE) {
|
||||
@@ -447,7 +447,7 @@ public class SQLStatementParser extends SQLParser {
|
||||
return stmt;
|
||||
}
|
||||
|
||||
public SQLStatement parseSet() throws ParserException {
|
||||
public SQLStatement parseSet() {
|
||||
accept(Token.SET);
|
||||
SQLSetStatement stmt = new SQLSetStatement();
|
||||
|
||||
@@ -470,7 +470,7 @@ public class SQLStatementParser extends SQLParser {
|
||||
}
|
||||
}
|
||||
|
||||
public SQLStatement parseCreate() throws ParserException {
|
||||
public SQLStatement parseCreate() {
|
||||
char mark_ch = lexer.current();
|
||||
int mark_bp = lexer.bp();
|
||||
|
||||
@@ -530,7 +530,7 @@ public class SQLStatementParser extends SQLParser {
|
||||
return new SQLCreateTableParser(this.exprParser);
|
||||
}
|
||||
|
||||
public SQLSelectStatement parseSelect() throws ParserException {
|
||||
public SQLSelectStatement parseSelect() {
|
||||
return new SQLSelectStatement(createSQLSelectParser().select());
|
||||
}
|
||||
|
||||
@@ -538,7 +538,7 @@ public class SQLStatementParser extends SQLParser {
|
||||
return new SQLSelectParser(this.exprParser);
|
||||
}
|
||||
|
||||
public SQLUpdateStatement parseUpdateStatement() throws ParserException {
|
||||
public SQLUpdateStatement parseUpdateStatement() {
|
||||
SQLUpdateStatement udpateStatement = createUpdateStatement();
|
||||
|
||||
if (lexer.token() == Token.UPDATE) {
|
||||
@@ -578,7 +578,7 @@ public class SQLStatementParser extends SQLParser {
|
||||
return new SQLUpdateStatement();
|
||||
}
|
||||
|
||||
public SQLDeleteStatement parseDeleteStatement() throws ParserException {
|
||||
public SQLDeleteStatement parseDeleteStatement() {
|
||||
SQLDeleteStatement deleteStatement = new SQLDeleteStatement();
|
||||
|
||||
if (lexer.token() == Token.DELETE) {
|
||||
@@ -601,13 +601,13 @@ public class SQLStatementParser extends SQLParser {
|
||||
return deleteStatement;
|
||||
}
|
||||
|
||||
public SQLCreateTableStatement parseCreateTable() throws ParserException {
|
||||
public SQLCreateTableStatement parseCreateTable() {
|
||||
// SQLCreateTableParser parser = new SQLCreateTableParser(this.lexer);
|
||||
// return parser.parseCrateTable();
|
||||
throw new ParserException("TODO");
|
||||
}
|
||||
|
||||
public SQLCreateViewStatement parseCreateView() throws ParserException {
|
||||
public SQLCreateViewStatement parseCreateView() {
|
||||
SQLCreateViewStatement createView = new SQLCreateViewStatement();
|
||||
|
||||
this.accept(Token.CREATE);
|
||||
|
||||
@@ -218,8 +218,6 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter {
|
||||
}
|
||||
|
||||
public boolean visit(SQLIdentifierExpr x) {
|
||||
String currentTable = getCurrentTable();
|
||||
|
||||
if (subQueryMap.containsKey(currentTable)) {
|
||||
return false;
|
||||
}
|
||||
@@ -252,13 +250,13 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter {
|
||||
|
||||
public void addOrderByColumn(String table, String columnName, SQLObject expr) {
|
||||
Column column = new Column(table, columnName);
|
||||
|
||||
|
||||
SQLObject parent = expr.getParent();
|
||||
if (parent instanceof SQLSelectOrderByItem) {
|
||||
SQLOrderingSpecification type = ((SQLSelectOrderByItem) parent).getType();
|
||||
column.getAttributes().put("orderBy.type", type);
|
||||
}
|
||||
|
||||
|
||||
orderByColumns.add(column);
|
||||
}
|
||||
}
|
||||
@@ -421,12 +419,10 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter {
|
||||
|
||||
String column = ((SQLIdentifierExpr) expr).getName();
|
||||
String table = getCurrentTable();
|
||||
if (table != null) {
|
||||
if (aliasMap.containsKey(table)) {
|
||||
table = aliasMap.get(table);
|
||||
if (table == null) {
|
||||
return null;
|
||||
}
|
||||
if (table != null && aliasMap.containsKey(table)) {
|
||||
table = aliasMap.get(table);
|
||||
if (table == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -548,14 +544,12 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (x.getInto() != null) {
|
||||
if (x.getInto().getExpr() instanceof SQLName) {
|
||||
SQLName into = (SQLName) x.getInto().getExpr();
|
||||
String ident = into.toString();
|
||||
TableStat stat = getTableStat(ident);
|
||||
if (stat != null) {
|
||||
stat.incrementInsertCount();
|
||||
}
|
||||
if (x.getInto() != null && x.getInto().getExpr() instanceof SQLName) {
|
||||
SQLName into = (SQLName) x.getInto().getExpr();
|
||||
String ident = into.toString();
|
||||
TableStat stat = getTableStat(ident);
|
||||
if (stat != null) {
|
||||
stat.incrementInsertCount();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -746,11 +740,9 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter {
|
||||
SQLSelectQuery query = x.getSelect().getQuery();
|
||||
|
||||
Map<String, String> aliasMap = getAliasMap();
|
||||
if (aliasMap != null) {
|
||||
if (x.getAlias() != null) {
|
||||
aliasMap.put(x.getAlias(), null);
|
||||
subQueryMap.put(x.getAlias(), query);
|
||||
}
|
||||
if (aliasMap != null && x.getAlias() != null) {
|
||||
aliasMap.put(x.getAlias(), null);
|
||||
subQueryMap.put(x.getAlias(), query);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -911,7 +903,7 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter {
|
||||
}
|
||||
|
||||
public void endVisit(SQLDeleteStatement x) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void endVisit(SQLUpdateStatement x) {
|
||||
|
||||
@@ -45,7 +45,7 @@ import com.alibaba.druid.util.StringUtils;
|
||||
*
|
||||
* @author sandzhang<sandzhangtoo@gmail.com>
|
||||
*/
|
||||
public class DruidStatManagerFacade {
|
||||
public final class DruidStatManagerFacade {
|
||||
|
||||
private final static DruidStatManagerFacade instance = new DruidStatManagerFacade();
|
||||
private boolean resetEnable = true;
|
||||
|
||||
@@ -44,7 +44,7 @@ import com.alibaba.druid.util.StringUtils;
|
||||
*
|
||||
* @author sandzhang<sandzhangtoo@gmail.com>
|
||||
*/
|
||||
public class DruidStatService implements DruidStatServiceMBean {
|
||||
public final class DruidStatService implements DruidStatServiceMBean {
|
||||
|
||||
private final static Log LOG = LogFactory.getLog(DruidStatService.class);
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.alibaba.druid.proxy.DruidDriver;
|
||||
import com.alibaba.druid.proxy.jdbc.DataSourceProxyImpl;
|
||||
|
||||
public class JdbcStatManager implements JdbcStatManagerMBean {
|
||||
public final class JdbcStatManager implements JdbcStatManagerMBean {
|
||||
|
||||
private final AtomicLong sqlIdSeed = new AtomicLong(1000);
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package com.alibaba.druid.support.http;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
@@ -510,9 +509,5 @@ public class WebStatFilter implements Filter {
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public PrintWriter getWriter() throws IOException {
|
||||
return super.getWriter();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -706,7 +706,7 @@ public class WebAppStat {
|
||||
} else if (userAgent.indexOf("FreeBSD") != -1) {
|
||||
osFreeBSDCount.incrementAndGet();
|
||||
isBSD = true;
|
||||
} else if (isLinux == false && userAgent.indexOf("Linux") != -1) {
|
||||
} else if ((!isLinux) && userAgent.indexOf("Linux") != -1) {
|
||||
osLinuxCount.incrementAndGet();
|
||||
isLinux = true;
|
||||
}
|
||||
|
||||
@@ -91,7 +91,6 @@ public class DruidSQLPanel extends DruidPanel {
|
||||
add("FetchRowCountHistogram");
|
||||
}
|
||||
};
|
||||
private RowHeaderTable header;
|
||||
|
||||
public DruidSQLPanel() {
|
||||
super();
|
||||
@@ -104,7 +103,7 @@ public class DruidSQLPanel extends DruidPanel {
|
||||
tableModel = new DruidTableModel(data,SHOW_LIST);
|
||||
table.setModel(tableModel);
|
||||
|
||||
header = new RowHeaderTable(table,20);
|
||||
RowHeaderTable header = new RowHeaderTable(table,20);
|
||||
scrollPane.setRowHeaderView(header);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import java.util.Properties;
|
||||
/**
|
||||
* A class to simplify access to resources through the classloader.
|
||||
*/
|
||||
public class Resources extends Object {
|
||||
public final class Resources extends Object {
|
||||
|
||||
private static ClassLoader defaultClassLoader;
|
||||
|
||||
@@ -79,7 +79,7 @@ public class Resources extends Object {
|
||||
*/
|
||||
public static URL getResourceURL(ClassLoader loader, String resource) throws IOException {
|
||||
URL url = null;
|
||||
|
||||
|
||||
if (loader != null) {
|
||||
url = loader.getResource(resource);
|
||||
}
|
||||
@@ -87,11 +87,11 @@ public class Resources extends Object {
|
||||
if (url == null) {
|
||||
url = ClassLoader.getSystemResource(resource);
|
||||
}
|
||||
|
||||
|
||||
if (url == null) {
|
||||
throw new IOException("Could not find resource " + resource);
|
||||
}
|
||||
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
@@ -414,7 +414,7 @@ public class WallVisitorUtils {
|
||||
|
||||
if (x instanceof SQLNotExpr) {
|
||||
Object result = getValue(((SQLNotExpr) x).getExpr());
|
||||
if (result != null && result instanceof Boolean) {
|
||||
if (result instanceof Boolean) {
|
||||
return !((Boolean) result).booleanValue();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user