Search in sources :

Example 26 with ResultSetProxy

use of com.alibaba.druid.proxy.jdbc.ResultSetProxy 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 27 with ResultSetProxy

use of com.alibaba.druid.proxy.jdbc.ResultSetProxy 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 28 with ResultSetProxy

use of com.alibaba.druid.proxy.jdbc.ResultSetProxy 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 29 with ResultSetProxy

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

the class StatFilterReadStringLengthTest 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 String resultSet_getString(FilterChain chain, ResultSetProxy result, int columnIndex) throws SQLException {
            return "123456";
        }

        @Override
        public String resultSet_getString(FilterChain chain, ResultSetProxy result, String columnIndex) throws SQLException {
            return "1234567";
        }
    });
    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)

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