Search in sources :

Example 31 with ConnectionProxy

use of com.alibaba.druid.proxy.jdbc.ConnectionProxy 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)

Example 32 with ConnectionProxy

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

the class DruidDataSourceTest_createError 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 {
            throw new SQLException();
        }
    });
}
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

ConnectionProxy (com.alibaba.druid.proxy.jdbc.ConnectionProxy)32 SQLException (java.sql.SQLException)19 FilterChain (com.alibaba.druid.filter.FilterChain)18 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)18 FilterAdapter (com.alibaba.druid.filter.FilterAdapter)17 Properties (java.util.Properties)13 DruidPooledConnection (com.alibaba.druid.pool.DruidPooledConnection)7 ResultSet (java.sql.ResultSet)5 MockResultSet (com.alibaba.druid.mock.MockResultSet)3 DataSourceProxy (com.alibaba.druid.proxy.jdbc.DataSourceProxy)3 DataSourceProxyConfig (com.alibaba.druid.proxy.jdbc.DataSourceProxyConfig)3 DataSourceProxyImpl (com.alibaba.druid.proxy.jdbc.DataSourceProxyImpl)3 Statement (java.sql.Statement)3 FilterChainImpl (com.alibaba.druid.filter.FilterChainImpl)2 FilterEventAdapter (com.alibaba.druid.filter.FilterEventAdapter)2 EncodingConvertFilter (com.alibaba.druid.filter.encoding.EncodingConvertFilter)2 ConnectionProxyImpl (com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl)2 PreparedStatementProxy (com.alibaba.druid.proxy.jdbc.PreparedStatementProxy)2 ResultSetProxyImpl (com.alibaba.druid.proxy.jdbc.ResultSetProxyImpl)2 StatementProxy (com.alibaba.druid.proxy.jdbc.StatementProxy)2