Search in sources :

Example 1 with ExceptionSorter

use of com.alibaba.druid.pool.ExceptionSorter in project druid by alibaba.

the class DruidDataSourceTest_exceptionSorter method setUp.

protected void setUp() throws Exception {
    dataSource = new DruidDataSource();
    dataSource.setUrl("jdbc:mock:xxx");
    dataSource.setTestOnBorrow(false);
    dataSource.setRemoveAbandoned(true);
    dataSource.setDriver(new MockDriver() {

        public ResultSet executeQuery(MockStatementBase stmt, String sql) throws SQLException {
            throw new SQLException();
        }
    });
    dataSource.setExceptionSorter(new ExceptionSorter() {

        @Override
        public boolean isExceptionFatal(SQLException e) {
            return true;
        }

        @Override
        public void configFromProperties(Properties properties) {
        }
    });
}
Also used : MockDriver(com.alibaba.druid.mock.MockDriver) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) ExceptionSorter(com.alibaba.druid.pool.ExceptionSorter) Properties(java.util.Properties) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) MockStatementBase(com.alibaba.druid.mock.MockStatementBase)

Aggregations

MockDriver (com.alibaba.druid.mock.MockDriver)1 MockStatementBase (com.alibaba.druid.mock.MockStatementBase)1 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)1 ExceptionSorter (com.alibaba.druid.pool.ExceptionSorter)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 Properties (java.util.Properties)1