Search in sources :

Example 11 with FilterAdapter

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

the class DruidPooledCallableStatementTest method setUp.

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

        public boolean callableStatement_wasNull(FilterChain chain, CallableStatementProxy statement) throws SQLException {
            if (throwError) {
                throw new SQLException();
            } else {
                return chain.callableStatement_wasNull(statement);
            }
        }
    });
}
Also used : SQLException(java.sql.SQLException) FilterChain(com.alibaba.druid.filter.FilterChain) FilterAdapter(com.alibaba.druid.filter.FilterAdapter) CallableStatementProxy(com.alibaba.druid.proxy.jdbc.CallableStatementProxy) DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Example 12 with FilterAdapter

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

the class DruidDataSourceTest_recycle2 method setUp.

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

        public void connection_rollback(FilterChain chain, ConnectionProxy connection) throws SQLException {
            throw new SQLException();
        }
    });
}
Also used : SQLException(java.sql.SQLException) FilterChain(com.alibaba.druid.filter.FilterChain) FilterAdapter(com.alibaba.druid.filter.FilterAdapter) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) ConnectionProxy(com.alibaba.druid.proxy.jdbc.ConnectionProxy)

Example 13 with FilterAdapter

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

the class DruidDataSourceTest3 method setUp.

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

        public ConnectionProxy connection_connect(FilterChain chain, Properties info) throws SQLException {
            try {
                Thread.sleep(Long.MAX_VALUE);
            } catch (InterruptedException e) {
            // skip
            }
            return null;
        }
    });
}
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 14 with FilterAdapter

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

the class DruidDataSourceTest7 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 RuntimeException();
        }
    });
}
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 15 with FilterAdapter

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

the class DruidDataSourceTest_lastError method setUp.

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

        public void connection_setAutoCommit(FilterChain chain, ConnectionProxy connection, boolean autoCommit) throws SQLException {
            throw new SQLException();
        }
    });
}
Also used : SQLException(java.sql.SQLException) FilterChain(com.alibaba.druid.filter.FilterChain) FilterAdapter(com.alibaba.druid.filter.FilterAdapter) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) ConnectionProxy(com.alibaba.druid.proxy.jdbc.ConnectionProxy)

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