Search in sources :

Example 1 with ResultSetProxy

use of com.alibaba.druid.proxy.jdbc.ResultSetProxy in project druid by alibaba.

the class WallFilter method preparedStatement_executeQuery.

@Override
public ResultSetProxy preparedStatement_executeQuery(FilterChain chain, PreparedStatementProxy statement) throws SQLException {
    try {
        ResultSetProxy resultSetProxy = chain.preparedStatement_executeQuery(statement);
        preprocessResultSet(resultSetProxy);
        return resultSetProxy;
    } catch (SQLException ex) {
        incrementExecuteErrorCount(statement);
        throw ex;
    }
}
Also used : SQLException(java.sql.SQLException) ResultSetProxy(com.alibaba.druid.proxy.jdbc.ResultSetProxy)

Example 2 with ResultSetProxy

use of com.alibaba.druid.proxy.jdbc.ResultSetProxy in project druid by alibaba.

the class WallFilter method statement_executeQuery.

@Override
public ResultSetProxy statement_executeQuery(FilterChain chain, StatementProxy statement, String sql) throws SQLException {
    createWallContext(statement);
    try {
        sql = check(sql);
        ResultSetProxy resultSetProxy = chain.statement_executeQuery(statement, sql);
        preprocessResultSet(resultSetProxy);
        return resultSetProxy;
    } catch (SQLException ex) {
        incrementExecuteErrorCount();
        throw ex;
    } finally {
        WallContext.clearContext();
    }
}
Also used : SQLException(java.sql.SQLException) ResultSetProxy(com.alibaba.druid.proxy.jdbc.ResultSetProxy)

Example 3 with ResultSetProxy

use of com.alibaba.druid.proxy.jdbc.ResultSetProxy in project druid by alibaba.

the class StatFilterExecErrorTest method setUp.

protected void setUp() throws Exception {
    dataSource = new DruidDataSource();
    dataSource.setUrl("jdbc:mock:xxx");
    dataSource.setFilters("stat");
    dataSource.setTestOnBorrow(false);
    dataSource.getProxyFilters().add(new FilterAdapter() {

        @Override
        public ResultSetProxy statement_executeQuery(FilterChain chain, StatementProxy statement, String sql) throws SQLException {
            throw new SQLException();
        }

        @Override
        public ResultSetProxy preparedStatement_executeQuery(FilterChain chain, PreparedStatementProxy statement) throws SQLException {
            throw new SQLException();
        }
    });
    dataSource.init();
}
Also used : SQLException(java.sql.SQLException) FilterChain(com.alibaba.druid.filter.FilterChain) StatementProxy(com.alibaba.druid.proxy.jdbc.StatementProxy) PreparedStatementProxy(com.alibaba.druid.proxy.jdbc.PreparedStatementProxy) FilterAdapter(com.alibaba.druid.filter.FilterAdapter) ResultSetProxy(com.alibaba.druid.proxy.jdbc.ResultSetProxy) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) PreparedStatementProxy(com.alibaba.druid.proxy.jdbc.PreparedStatementProxy)

Example 4 with ResultSetProxy

use of com.alibaba.druid.proxy.jdbc.ResultSetProxy in project druid by alibaba.

the class StatFilterOpenBlobCountTest method setUp.

protected void setUp() throws Exception {
    dataSource = new DruidDataSource();
    dataSource.setUrl("jdbc:mock:xxx");
    dataSource.setFilters("stat");
    dataSource.setTestOnBorrow(false);
    dataSource.getProxyFilters().add(new FilterAdapter() {

        @Override
        public Blob resultSet_getBlob(FilterChain chain, ResultSetProxy result, int columnIndex) throws SQLException {
            return new MockBlob();
        }

        @Override
        public Blob resultSet_getBlob(FilterChain chain, ResultSetProxy result, String columnLabel) throws SQLException {
            return new MockBlob();
        }
    });
    dataSource.init();
}
Also used : MockBlob(com.alibaba.druid.mock.MockBlob) Blob(java.sql.Blob) SQLException(java.sql.SQLException) MockBlob(com.alibaba.druid.mock.MockBlob) FilterChain(com.alibaba.druid.filter.FilterChain) FilterAdapter(com.alibaba.druid.filter.FilterAdapter) ResultSetProxy(com.alibaba.druid.proxy.jdbc.ResultSetProxy) DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Example 5 with ResultSetProxy

use of com.alibaba.druid.proxy.jdbc.ResultSetProxy in project druid by alibaba.

the class StatFilterOpenBlobCountTest2 method setUp.

protected void setUp() throws Exception {
    dataSource = new DruidDataSource();
    dataSource.setUrl("jdbc:mock:xxx");
    dataSource.setFilters("stat");
    dataSource.setTestOnBorrow(false);
    dataSource.getProxyFilters().add(new FilterAdapter() {

        @Override
        public Object resultSet_getObject(FilterChain chain, ResultSetProxy result, int columnIndex) throws SQLException {
            return new MockBlob();
        }

        @Override
        public Object resultSet_getObject(FilterChain chain, ResultSetProxy result, String columnLabel) throws SQLException {
            return new MockBlob();
        }

        @Override
        public Object resultSet_getObject(FilterChain chain, ResultSetProxy result, int columnIndex, java.util.Map<String, Class<?>> map) throws SQLException {
            return new MockBlob();
        }

        @Override
        public Object resultSet_getObject(FilterChain chain, ResultSetProxy result, String columnIndex, java.util.Map<String, Class<?>> map) throws SQLException {
            return new MockBlob();
        }
    });
    dataSource.init();
}
Also used : SQLException(java.sql.SQLException) MockBlob(com.alibaba.druid.mock.MockBlob) FilterChain(com.alibaba.druid.filter.FilterChain) FilterAdapter(com.alibaba.druid.filter.FilterAdapter) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) ResultSetProxy(com.alibaba.druid.proxy.jdbc.ResultSetProxy)

Aggregations

ResultSetProxy (com.alibaba.druid.proxy.jdbc.ResultSetProxy)29 SQLException (java.sql.SQLException)17 FilterChain (com.alibaba.druid.filter.FilterChain)13 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)13 FilterAdapter (com.alibaba.druid.filter.FilterAdapter)12 FilterChainImpl (com.alibaba.druid.filter.FilterChainImpl)9 MockResultSet (com.alibaba.druid.mock.MockResultSet)9 ResultSet (java.sql.ResultSet)8 ResultSetProxyImpl (com.alibaba.druid.proxy.jdbc.ResultSetProxyImpl)6 StatementProxy (com.alibaba.druid.proxy.jdbc.StatementProxy)4 DataSourceProxyConfig (com.alibaba.druid.proxy.jdbc.DataSourceProxyConfig)3 DataSourceProxyImpl (com.alibaba.druid.proxy.jdbc.DataSourceProxyImpl)3 PreparedStatementProxy (com.alibaba.druid.proxy.jdbc.PreparedStatementProxy)3 StatFilter (com.alibaba.druid.filter.stat.StatFilter)2 MockBlob (com.alibaba.druid.mock.MockBlob)2 MockClob (com.alibaba.druid.mock.MockClob)2 MockDriver (com.alibaba.druid.mock.MockDriver)2 ClobProxyImpl (com.alibaba.druid.proxy.jdbc.ClobProxyImpl)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 Connection (java.sql.Connection)2