Search in sources :

Example 31 with FilterChain

use of com.alibaba.druid.filter.FilterChain 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)

Example 32 with FilterChain

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

the class DruidDataSourceTest8 method setUp.

protected void setUp() throws Exception {
    dataSource = new DruidDataSource();
    dataSource.setUrl("jdbc:mock:xxx");
    dataSource.setInitialSize(1);
    dataSource.getProxyFilters().add(new FilterAdapter() {

        @Override
        public ConnectionProxy connection_connect(FilterChain chain, Properties info) throws SQLException {
            throw new Error();
        }
    });
}
Also used : SQLException(java.sql.SQLException) FilterChain(com.alibaba.druid.filter.FilterChain) FilterAdapter(com.alibaba.druid.filter.FilterAdapter) Properties(java.util.Properties) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) ConnectionProxy(com.alibaba.druid.proxy.jdbc.ConnectionProxy)

Example 33 with FilterChain

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

the class DruidDataSourceTest_autocommit method setUp.

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

        public ConnectionProxy connection_connect(FilterChain chain, Properties info) throws SQLException {
            ConnectionProxy conn = chain.connection_connect(info);
            conn.setAutoCommit(false);
            return conn;
        }
    });
}
Also used : SQLException(java.sql.SQLException) FilterChain(com.alibaba.druid.filter.FilterChain) FilterAdapter(com.alibaba.druid.filter.FilterAdapter) Properties(java.util.Properties) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) ConnectionProxy(com.alibaba.druid.proxy.jdbc.ConnectionProxy)

Example 34 with FilterChain

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

the class DruidDataSourceTest_autocommit2 method setUp.

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

        public ConnectionProxy connection_connect(FilterChain chain, Properties info) throws SQLException {
            ConnectionProxy conn = chain.connection_connect(info);
            conn.setAutoCommit(true);
            return conn;
        }
    });
}
Also used : SQLException(java.sql.SQLException) FilterChain(com.alibaba.druid.filter.FilterChain) FilterAdapter(com.alibaba.druid.filter.FilterAdapter) Properties(java.util.Properties) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) ConnectionProxy(com.alibaba.druid.proxy.jdbc.ConnectionProxy)

Example 35 with FilterChain

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

the class DruidDataSourceTest_autocommit4 method setUp.

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

        public ConnectionProxy connection_connect(FilterChain chain, Properties info) throws SQLException {
            ConnectionProxy conn = chain.connection_connect(info);
            conn.setAutoCommit(true);
            return conn;
        }
    });
}
Also used : SQLException(java.sql.SQLException) FilterChain(com.alibaba.druid.filter.FilterChain) FilterAdapter(com.alibaba.druid.filter.FilterAdapter) Properties(java.util.Properties) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) ConnectionProxy(com.alibaba.druid.proxy.jdbc.ConnectionProxy)

Aggregations

FilterChain (com.alibaba.druid.filter.FilterChain)36 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)33 SQLException (java.sql.SQLException)33 FilterAdapter (com.alibaba.druid.filter.FilterAdapter)32 ConnectionProxy (com.alibaba.druid.proxy.jdbc.ConnectionProxy)18 ResultSetProxy (com.alibaba.druid.proxy.jdbc.ResultSetProxy)13 Properties (java.util.Properties)12 StatementProxy (com.alibaba.druid.proxy.jdbc.StatementProxy)6 PreparedStatementProxy (com.alibaba.druid.proxy.jdbc.PreparedStatementProxy)4 FilterChainImpl (com.alibaba.druid.filter.FilterChainImpl)3 DataSourceProxyImpl (com.alibaba.druid.proxy.jdbc.DataSourceProxyImpl)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 ConnectionProxyImpl (com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl)2 DataSourceProxyConfig (com.alibaba.druid.proxy.jdbc.DataSourceProxyConfig)2 ResultSetProxyImpl (com.alibaba.druid.proxy.jdbc.ResultSetProxyImpl)2 Log (com.alibaba.druid.support.logging.Log)2 Log4jImpl (com.alibaba.druid.support.logging.Log4jImpl)2