Search in sources :

Example 21 with FilterAdapter

use of com.alibaba.druid.filter.FilterAdapter in project druid by alibaba.

the class StatFilterOpenInputStreamCountTest 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 java.io.InputStream resultSet_getBinaryStream(FilterChain chain, ResultSetProxy result, int columnIndex) throws SQLException {
            return new ByteArrayInputStream(new byte[0]);
        }

        @Override
        public java.io.InputStream resultSet_getBinaryStream(FilterChain chain, ResultSetProxy result, String columnLabel) throws SQLException {
            return new ByteArrayInputStream(new byte[0]);
        }
    });
    dataSource.init();
}
Also used : SQLException(java.sql.SQLException) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) 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 22 with FilterAdapter

use of com.alibaba.druid.filter.FilterAdapter in project druid by alibaba.

the class StatFilterOpenReaderCountTest 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 java.io.Reader resultSet_getCharacterStream(FilterChain chain, ResultSetProxy result, int columnIndex) throws SQLException {
            return new StringReader("");
        }

        @Override
        public java.io.Reader resultSet_getCharacterStream(FilterChain chain, ResultSetProxy result, String columnLabel) throws SQLException {
            return new StringReader("");
        }
    });
    dataSource.init();
}
Also used : SQLException(java.sql.SQLException) FilterChain(com.alibaba.druid.filter.FilterChain) StringReader(org.nutz.lang.stream.StringReader) FilterAdapter(com.alibaba.druid.filter.FilterAdapter) StringReader(org.nutz.lang.stream.StringReader) ResultSetProxy(com.alibaba.druid.proxy.jdbc.ResultSetProxy) DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Example 23 with FilterAdapter

use of com.alibaba.druid.filter.FilterAdapter in project druid by alibaba.

the class StatFilterOpenInputStreamCountTest2 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 java.io.InputStream resultSet_getAsciiStream(FilterChain chain, ResultSetProxy result, int columnIndex) throws SQLException {
            return new ByteArrayInputStream(new byte[0]);
        }

        @Override
        public java.io.InputStream resultSet_getAsciiStream(FilterChain chain, ResultSetProxy result, String columnLabel) throws SQLException {
            return new ByteArrayInputStream(new byte[0]);
        }
    });
    dataSource.init();
}
Also used : SQLException(java.sql.SQLException) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) 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 24 with FilterAdapter

use of com.alibaba.druid.filter.FilterAdapter in project druid by alibaba.

the class StatFilterReadBytesLengthTest 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 byte[] resultSet_getBytes(FilterChain chain, ResultSetProxy result, int columnIndex) throws SQLException {
            return new byte[6];
        }

        @Override
        public byte[] resultSet_getBytes(FilterChain chain, ResultSetProxy result, String columnIndex) throws SQLException {
            return new byte[7];
        }
    });
    dataSource.init();
}
Also used : SQLException(java.sql.SQLException) 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 25 with FilterAdapter

use of com.alibaba.druid.filter.FilterAdapter in project druid by alibaba.

the class FilterChainImplTest method setUp.

protected void setUp() throws Exception {
    dataSource = new DruidDataSource();
    dataSource.setUrl("jdbc:mock:xxx");
    dataSource.setFilters("stat,log4j,wall,encoding");
    dataSource.getProxyFilters().add(new FilterAdapter() {
    });
    dataSource.setDbType("mysql");
    dataSource.init();
}
Also used : FilterAdapter(com.alibaba.druid.filter.FilterAdapter) DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Aggregations

FilterAdapter (com.alibaba.druid.filter.FilterAdapter)35 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)35 FilterChain (com.alibaba.druid.filter.FilterChain)32 SQLException (java.sql.SQLException)32 ConnectionProxy (com.alibaba.druid.proxy.jdbc.ConnectionProxy)17 ResultSetProxy (com.alibaba.druid.proxy.jdbc.ResultSetProxy)12 Properties (java.util.Properties)9 StatementProxy (com.alibaba.druid.proxy.jdbc.StatementProxy)5 PreparedStatementProxy (com.alibaba.druid.proxy.jdbc.PreparedStatementProxy)3 MockBlob (com.alibaba.druid.mock.MockBlob)2 MockClob (com.alibaba.druid.mock.MockClob)2 CallableStatementProxy (com.alibaba.druid.proxy.jdbc.CallableStatementProxy)2 ClobProxyImpl (com.alibaba.druid.proxy.jdbc.ClobProxyImpl)2 Log (com.alibaba.druid.support.logging.Log)2 Log4jImpl (com.alibaba.druid.support.logging.Log4jImpl)2 NoLoggingImpl (com.alibaba.druid.support.logging.NoLoggingImpl)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 Field (java.lang.reflect.Field)2 Filter (com.alibaba.druid.filter.Filter)1 MockConnection (com.alibaba.druid.mock.MockConnection)1