This commit is contained in:
温少
2012-03-20 05:03:17 +08:00
parent b510ea42f9
commit fe68104b69
2 changed files with 26 additions and 23 deletions
@@ -3,7 +3,6 @@ package com.alibaba.druid.wall;
import java.sql.SQLException;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import com.alibaba.druid.DruidRuntimeException;
@@ -131,23 +130,24 @@ public class WallFilter extends FilterAdapter implements WallFilterMBean {
throw new DruidRuntimeException("wall filter is inited");
}
}
@Override
public ConnectionProxy connection_connect(FilterChain chain, Properties info) throws SQLException {
return chain.connection_connect(info);
public void statement_addBatch(FilterChain chain, StatementProxy statement, String sql) throws SQLException {
check(sql);
chain.statement_addBatch(statement, sql);
}
@Override
public PreparedStatementProxy connection_prepareStatement(FilterChain chain, ConnectionProxy connection, String sql)
throws SQLException {
check(connection, sql);
check(sql);
return chain.connection_prepareStatement(connection, sql);
}
@Override
public PreparedStatementProxy connection_prepareStatement(FilterChain chain, ConnectionProxy connection,
String sql, int autoGeneratedKeys) throws SQLException {
check(connection, sql);
check(sql);
return chain.connection_prepareStatement(connection, sql, autoGeneratedKeys);
}
@@ -155,7 +155,7 @@ public class WallFilter extends FilterAdapter implements WallFilterMBean {
public PreparedStatementProxy connection_prepareStatement(FilterChain chain, ConnectionProxy connection,
String sql, int resultSetType, int resultSetConcurrency)
throws SQLException {
check(connection, sql);
check(sql);
return chain.connection_prepareStatement(connection, sql, resultSetType, resultSetConcurrency);
}
@@ -163,7 +163,7 @@ public class WallFilter extends FilterAdapter implements WallFilterMBean {
public PreparedStatementProxy connection_prepareStatement(FilterChain chain, ConnectionProxy connection,
String sql, int resultSetType, int resultSetConcurrency,
int resultSetHoldability) throws SQLException {
check(connection, sql);
check(sql);
return chain.connection_prepareStatement(connection, sql, resultSetType, resultSetConcurrency,
resultSetHoldability);
}
@@ -171,21 +171,21 @@ public class WallFilter extends FilterAdapter implements WallFilterMBean {
@Override
public PreparedStatementProxy connection_prepareStatement(FilterChain chain, ConnectionProxy connection,
String sql, int[] columnIndexes) throws SQLException {
check(connection, sql);
check(sql);
return chain.connection_prepareStatement(connection, sql, columnIndexes);
}
@Override
public PreparedStatementProxy connection_prepareStatement(FilterChain chain, ConnectionProxy connection,
String sql, String[] columnNames) throws SQLException {
check(connection, sql);
check(sql);
return chain.connection_prepareStatement(connection, sql, columnNames);
}
@Override
public CallableStatementProxy connection_prepareCall(FilterChain chain, ConnectionProxy connection, String sql)
throws SQLException {
check(connection, sql);
check(sql);
return chain.connection_prepareCall(connection, sql);
}
@@ -193,7 +193,7 @@ public class WallFilter extends FilterAdapter implements WallFilterMBean {
public CallableStatementProxy connection_prepareCall(FilterChain chain, ConnectionProxy connection, String sql,
int resultSetType, int resultSetConcurrency)
throws SQLException {
check(connection, sql);
check(sql);
return chain.connection_prepareCall(connection, sql, resultSetType, resultSetConcurrency);
}
@@ -201,7 +201,7 @@ public class WallFilter extends FilterAdapter implements WallFilterMBean {
public CallableStatementProxy connection_prepareCall(FilterChain chain, ConnectionProxy connection, String sql,
int resultSetType, int resultSetConcurrency,
int resultSetHoldability) throws SQLException {
check(connection, sql);
check(sql);
return chain.connection_prepareCall(connection, sql, resultSetType, resultSetConcurrency, resultSetHoldability);
}
@@ -209,66 +209,66 @@ public class WallFilter extends FilterAdapter implements WallFilterMBean {
@Override
public boolean statement_execute(FilterChain chain, StatementProxy statement, String sql) throws SQLException {
check(statement.getConnectionProxy(), sql);
check(sql);
return chain.statement_execute(statement, sql);
}
@Override
public boolean statement_execute(FilterChain chain, StatementProxy statement, String sql, int autoGeneratedKeys)
throws SQLException {
check(statement.getConnectionProxy(), sql);
check(sql);
return chain.statement_execute(statement, sql, autoGeneratedKeys);
}
@Override
public boolean statement_execute(FilterChain chain, StatementProxy statement, String sql, int columnIndexes[])
throws SQLException {
check(statement.getConnectionProxy(), sql);
check(sql);
return chain.statement_execute(statement, sql, columnIndexes);
}
@Override
public boolean statement_execute(FilterChain chain, StatementProxy statement, String sql, String columnNames[])
throws SQLException {
check(statement.getConnectionProxy(), sql);
check(sql);
return chain.statement_execute(statement, sql, columnNames);
}
@Override
public ResultSetProxy statement_executeQuery(FilterChain chain, StatementProxy statement, String sql)
throws SQLException {
check(statement.getConnectionProxy(), sql);
check(sql);
return chain.statement_executeQuery(statement, sql);
}
@Override
public int statement_executeUpdate(FilterChain chain, StatementProxy statement, String sql) throws SQLException {
check(statement.getConnectionProxy(), sql);
check(sql);
return chain.statement_executeUpdate(statement, sql);
}
@Override
public int statement_executeUpdate(FilterChain chain, StatementProxy statement, String sql, int autoGeneratedKeys)
throws SQLException {
check(statement.getConnectionProxy(), sql);
check(sql);
return chain.statement_executeUpdate(statement, sql, autoGeneratedKeys);
}
@Override
public int statement_executeUpdate(FilterChain chain, StatementProxy statement, String sql, int columnIndexes[])
throws SQLException {
check(statement.getConnectionProxy(), sql);
check(sql);
return chain.statement_executeUpdate(statement, sql, columnIndexes);
}
@Override
public int statement_executeUpdate(FilterChain chain, StatementProxy statement, String sql, String columnNames[])
throws SQLException {
check(statement.getConnectionProxy(), sql);
check(sql);
return chain.statement_executeUpdate(statement, sql, columnNames);
}
public void check(ConnectionProxy connection, String sql) throws SQLException {
public void check(String sql) throws SQLException {
List<Violation> violations = provider.check(sql);
if (violations.size() > 0) {
@@ -1,5 +1,6 @@
package com.alibaba.druid.wall;
import java.sql.SQLException;
import java.util.Set;
public interface WallFilterMBean {
@@ -19,4 +20,6 @@ public interface WallFilterMBean {
void clearProviderCache();
Set<String> getProviderWhiteList();
void check(String sql) throws SQLException;
}