Search in sources :

Example 16 with ResultSetProxy

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

the class FilterEventAdapter method statement_executeQuery.

@Override
public ResultSetProxy statement_executeQuery(FilterChain chain, StatementProxy statement, String sql) throws SQLException {
    statementExecuteQueryBefore(statement, sql);
    try {
        ResultSetProxy resultSet = super.statement_executeQuery(chain, statement, sql);
        if (resultSet != null) {
            statementExecuteQueryAfter(statement, sql, resultSet);
            resultSetOpenAfter(resultSet);
        }
        return resultSet;
    } catch (SQLException error) {
        statement_executeErrorAfter(statement, sql, error);
        throw error;
    } catch (RuntimeException error) {
        statement_executeErrorAfter(statement, sql, error);
        throw error;
    } catch (Error error) {
        statement_executeErrorAfter(statement, sql, error);
        throw error;
    }
}
Also used : SQLException(java.sql.SQLException) ResultSetProxy(com.alibaba.druid.proxy.jdbc.ResultSetProxy)

Example 17 with ResultSetProxy

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

the class WallFilter method statement_getGeneratedKeys.

@Override
public ResultSetProxy statement_getGeneratedKeys(FilterChain chain, StatementProxy statement) throws SQLException {
    ResultSetProxy resultSetProxy = chain.statement_getGeneratedKeys(statement);
    preprocessResultSet(resultSetProxy);
    return resultSetProxy;
}
Also used : ResultSetProxy(com.alibaba.druid.proxy.jdbc.ResultSetProxy)

Example 18 with ResultSetProxy

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

the class WallFilter method statement_getResultSet.

@Override
public ResultSetProxy statement_getResultSet(FilterChain chain, StatementProxy statement) throws SQLException {
    ResultSetProxy resultSetProxy = chain.statement_getResultSet(statement);
    preprocessResultSet(resultSetProxy);
    return resultSetProxy;
}
Also used : ResultSetProxy(com.alibaba.druid.proxy.jdbc.ResultSetProxy)

Example 19 with ResultSetProxy

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

the class JdbcFilterEventAdapterTest method test_filterEventAdapter.

public void test_filterEventAdapter() throws Exception {
    DataSourceProxyConfig config = new DataSourceProxyConfig();
    DataSourceProxy dataSource = new DataSourceProxyImpl(null, config);
    FilterEventAdapter filter = new FilterEventAdapter() {
    };
    String sql = "SELECT * FROM PATROL";
    ConnectionProxy connection = new ConnectionProxyImpl(dataSource, null, new Properties(), 1001);
    final PreparedStatementProxy statement = new PreparedStatementProxyImpl(connection, null, sql, 1002);
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public boolean statement_execute(StatementProxy statement, String sql) throws SQLException {
                throw new SQLException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_execute(chain, statement, sql);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public boolean statement_execute(StatementProxy statement, String sql) throws SQLException {
                throw new RuntimeException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_execute(chain, statement, sql);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public boolean statement_execute(StatementProxy statement, String sql) throws SQLException {
                throw new Error();
            }
        };
        Throwable error = null;
        try {
            filter.statement_execute(chain, statement, sql);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    // //////////////////////////
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public boolean statement_execute(StatementProxy statement, String sql, int autoGeneratedKeys) throws SQLException {
                throw new SQLException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_execute(chain, statement, sql, Statement.NO_GENERATED_KEYS);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public boolean statement_execute(StatementProxy statement, String sql, int autoGeneratedKeys) throws SQLException {
                throw new RuntimeException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_execute(chain, statement, sql, Statement.NO_GENERATED_KEYS);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public boolean statement_execute(StatementProxy statement, String sql, int autoGeneratedKeys) throws SQLException {
                throw new Error();
            }
        };
        Throwable error = null;
        try {
            filter.statement_execute(chain, statement, sql, Statement.NO_GENERATED_KEYS);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    // //////////////////////////
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public boolean statement_execute(StatementProxy statement, String sql, int[] columnIndexes) throws SQLException {
                throw new SQLException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_execute(chain, statement, sql, new int[0]);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public boolean statement_execute(StatementProxy statement, String sql, int[] columnIndexes) throws SQLException {
                throw new RuntimeException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_execute(chain, statement, sql, new int[0]);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public boolean statement_execute(StatementProxy statement, String sql, int[] columnIndexes) throws SQLException {
                throw new Error();
            }
        };
        Throwable error = null;
        try {
            filter.statement_execute(chain, statement, sql, new int[0]);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    // //////////////////////////
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public boolean statement_execute(StatementProxy statement, String sql, String[] columnNames) throws SQLException {
                throw new SQLException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_execute(chain, statement, sql, new String[0]);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public boolean statement_execute(StatementProxy statement, String sql, String[] columnNames) throws SQLException {
                throw new RuntimeException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_execute(chain, statement, sql, new String[0]);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public boolean statement_execute(StatementProxy statement, String sql, String[] columnNames) throws SQLException {
                throw new Error();
            }
        };
        Throwable error = null;
        try {
            filter.statement_execute(chain, statement, sql, new String[0]);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    // //////////////////////////
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int[] statement_executeBatch(StatementProxy statement) throws SQLException {
                throw new SQLException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeBatch(chain, statement);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int[] statement_executeBatch(StatementProxy statement) throws SQLException {
                throw new RuntimeException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeBatch(chain, statement);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int[] statement_executeBatch(StatementProxy statement) throws SQLException {
                throw new Error();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeBatch(chain, statement);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    // //////////////////////////
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public ResultSetProxy statement_executeQuery(StatementProxy statement, String sql) throws SQLException {
                throw new SQLException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeQuery(chain, statement, sql);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public ResultSetProxy statement_executeQuery(StatementProxy statement, String sql) throws SQLException {
                throw new RuntimeException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeQuery(chain, statement, sql);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public ResultSetProxy statement_executeQuery(StatementProxy statement, String sql) throws SQLException {
                throw new Error();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeQuery(chain, statement, sql);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    // //////////////////////////
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int preparedStatement_executeUpdate(PreparedStatementProxy statement) throws SQLException {
                throw new SQLException();
            }
        };
        Throwable error = null;
        try {
            filter.preparedStatement_executeUpdate(chain, statement);
        } catch (SQLException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int preparedStatement_executeUpdate(PreparedStatementProxy statement) throws SQLException {
                throw new RuntimeException();
            }
        };
        Throwable error = null;
        try {
            filter.preparedStatement_executeUpdate(chain, statement);
        } catch (RuntimeException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int preparedStatement_executeUpdate(PreparedStatementProxy statement) throws SQLException {
                throw new Error();
            }
        };
        Throwable error = null;
        try {
            filter.preparedStatement_executeUpdate(chain, statement);
        } catch (Error ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    // //////////////////////////
    // //////////////////////////
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int statement_executeUpdate(StatementProxy statement, String sql) throws SQLException {
                throw new SQLException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeUpdate(chain, statement, sql);
        } catch (SQLException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int statement_executeUpdate(StatementProxy statement, String sql) throws SQLException {
                throw new RuntimeException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeUpdate(chain, statement, sql);
        } catch (RuntimeException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int statement_executeUpdate(StatementProxy statement, String sql) throws SQLException {
                throw new Error();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeUpdate(chain, statement, sql);
        } catch (Error ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    // //////////////////////////
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int statement_executeUpdate(StatementProxy statement, String sql, int autoGeneratedKeys) throws SQLException {
                throw new SQLException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeUpdate(chain, statement, sql, Statement.NO_GENERATED_KEYS);
        } catch (SQLException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int statement_executeUpdate(StatementProxy statement, String sql, int autoGeneratedKeys) throws SQLException {
                throw new RuntimeException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeUpdate(chain, statement, sql, Statement.NO_GENERATED_KEYS);
        } catch (RuntimeException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int statement_executeUpdate(StatementProxy statement, String sql, int autoGeneratedKeys) throws SQLException {
                throw new Error();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeUpdate(chain, statement, sql, Statement.NO_GENERATED_KEYS);
        } catch (Error ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    // //////////////////////////
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int statement_executeUpdate(StatementProxy statement, String sql, int[] columnIndexes) throws SQLException {
                throw new SQLException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeUpdate(chain, statement, sql, new int[0]);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int statement_executeUpdate(StatementProxy statement, String sql, int[] columnIndexes) throws SQLException {
                throw new RuntimeException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeUpdate(chain, statement, sql, new int[0]);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int statement_executeUpdate(StatementProxy statement, String sql, int[] columnIndexes) throws SQLException {
                throw new Error();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeUpdate(chain, statement, sql, new int[0]);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    // //////////////////////////
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int statement_executeUpdate(StatementProxy statement, String sql, String[] columnNames) throws SQLException {
                throw new SQLException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeUpdate(chain, statement, sql, new String[0]);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int statement_executeUpdate(StatementProxy statement, String sql, String[] columnNames) throws SQLException {
                throw new RuntimeException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeUpdate(chain, statement, sql, new String[0]);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int statement_executeUpdate(StatementProxy statement, String sql, String[] columnNames) throws SQLException {
                throw new Error();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeUpdate(chain, statement, sql, new String[0]);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    // ///////////////////////////
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public ResultSetProxy statement_getGeneratedKeys(StatementProxy statement) throws SQLException {
                return null;
            }
        };
        filter.statement_getGeneratedKeys(chain, statement);
    }
    {
        final ResultSetProxy resultSet = new ResultSetProxyImpl(statement, null, 2001, null);
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public ResultSetProxy statement_getGeneratedKeys(StatementProxy statement) throws SQLException {
                return resultSet;
            }
        };
        filter.statement_getGeneratedKeys(chain, statement);
    }
    // //////////////////////////
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public boolean preparedStatement_execute(PreparedStatementProxy statement) throws SQLException {
                throw new SQLException();
            }
        };
        Throwable error = null;
        try {
            filter.preparedStatement_execute(chain, statement);
        } catch (SQLException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public boolean preparedStatement_execute(PreparedStatementProxy statement) throws SQLException {
                throw new RuntimeException();
            }
        };
        Throwable error = null;
        try {
            filter.preparedStatement_execute(chain, statement);
        } catch (RuntimeException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public boolean preparedStatement_execute(PreparedStatementProxy statement) throws SQLException {
                throw new Error();
            }
        };
        Throwable error = null;
        try {
            filter.preparedStatement_execute(chain, statement);
        } catch (Error ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    // //////////////////////////
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public ResultSetProxy preparedStatement_executeQuery(PreparedStatementProxy statement) throws SQLException {
                throw new SQLException();
            }
        };
        Throwable error = null;
        try {
            filter.preparedStatement_executeQuery(chain, statement);
        } catch (SQLException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public ResultSetProxy preparedStatement_executeQuery(PreparedStatementProxy statement) throws SQLException {
                throw new RuntimeException();
            }
        };
        Throwable error = null;
        try {
            filter.preparedStatement_executeQuery(chain, statement);
        } catch (RuntimeException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public ResultSetProxy preparedStatement_executeQuery(PreparedStatementProxy statement) throws SQLException {
                throw new Error();
            }
        };
        Throwable error = null;
        try {
            filter.preparedStatement_executeQuery(chain, statement);
        } catch (Error ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    // //////////////////////////
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public void dataSource_recycle(DruidPooledConnection connection) throws SQLException {
                throw new SQLException();
            }
        };
        Throwable error = null;
        try {
            filter.dataSource_releaseConnection(chain, null);
        } catch (SQLException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public void dataSource_recycle(DruidPooledConnection connection) throws SQLException {
                throw new RuntimeException();
            }
        };
        Throwable error = null;
        try {
            filter.dataSource_releaseConnection(chain, null);
        } catch (RuntimeException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public void dataSource_recycle(DruidPooledConnection connection) throws SQLException {
                throw new Error();
            }
        };
        Throwable error = null;
        try {
            filter.dataSource_releaseConnection(chain, null);
        } catch (Error ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    // //////////////////////////
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public DruidPooledConnection dataSource_connect(DruidDataSource dataSource, long maxWaitMillis) throws SQLException {
                throw new SQLException();
            }
        };
        Throwable error = null;
        try {
            filter.dataSource_getConnection(chain, null, 0L);
        } catch (SQLException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public DruidPooledConnection dataSource_connect(DruidDataSource dataSource, long maxWaitMillis) throws SQLException {
                throw new RuntimeException();
            }
        };
        Throwable error = null;
        try {
            filter.dataSource_getConnection(chain, null, 0L);
        } catch (RuntimeException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public DruidPooledConnection dataSource_connect(DruidDataSource dataSource, long maxWaitMillis) throws SQLException {
                throw new Error();
            }
        };
        Throwable error = null;
        try {
            filter.dataSource_getConnection(chain, null, 0L);
        } catch (Error ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
}
Also used : SQLException(java.sql.SQLException) FilterChain(com.alibaba.druid.filter.FilterChain) ConnectionProxyImpl(com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl) Properties(java.util.Properties) ConnectionProxy(com.alibaba.druid.proxy.jdbc.ConnectionProxy) DruidPooledConnection(com.alibaba.druid.pool.DruidPooledConnection) PreparedStatementProxy(com.alibaba.druid.proxy.jdbc.PreparedStatementProxy) FilterChainImpl(com.alibaba.druid.filter.FilterChainImpl) DataSourceProxyConfig(com.alibaba.druid.proxy.jdbc.DataSourceProxyConfig) PreparedStatementProxyImpl(com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl) DataSourceProxy(com.alibaba.druid.proxy.jdbc.DataSourceProxy) DataSourceProxyImpl(com.alibaba.druid.proxy.jdbc.DataSourceProxyImpl) ResultSetProxyImpl(com.alibaba.druid.proxy.jdbc.ResultSetProxyImpl) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) FilterEventAdapter(com.alibaba.druid.filter.FilterEventAdapter) StatementProxy(com.alibaba.druid.proxy.jdbc.StatementProxy) PreparedStatementProxy(com.alibaba.druid.proxy.jdbc.PreparedStatementProxy) ResultSetProxy(com.alibaba.druid.proxy.jdbc.ResultSetProxy)

Example 20 with ResultSetProxy

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

the class StatFilterOpenClobCountTest 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 Clob resultSet_getClob(FilterChain chain, ResultSetProxy result, int columnIndex) throws SQLException {
            return new ClobProxyImpl(result.getStatementProxy().getConnectionProxy().getDirectDataSource(), result.getStatementProxy().getConnectionProxy(), new MockClob());
        }

        @Override
        public Clob resultSet_getClob(FilterChain chain, ResultSetProxy result, String columnLabel) throws SQLException {
            return new ClobProxyImpl(result.getStatementProxy().getConnectionProxy().getDirectDataSource(), result.getStatementProxy().getConnectionProxy(), new MockClob());
        }
    });
    dataSource.init();
}
Also used : ClobProxyImpl(com.alibaba.druid.proxy.jdbc.ClobProxyImpl) SQLException(java.sql.SQLException) FilterChain(com.alibaba.druid.filter.FilterChain) MockClob(com.alibaba.druid.mock.MockClob) FilterAdapter(com.alibaba.druid.filter.FilterAdapter) ResultSetProxy(com.alibaba.druid.proxy.jdbc.ResultSetProxy) MockClob(com.alibaba.druid.mock.MockClob) Clob(java.sql.Clob) DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

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