Search in sources :

Example 1 with MySqlExceptionSorter

use of com.alibaba.druid.pool.vendor.MySqlExceptionSorter in project druid by alibaba.

the class DiscardTest method setUp.

protected void setUp() throws Exception {
    driver = new MockDriver() {

        public ResultSet executeQuery(MockStatementBase stmt, String sql) throws SQLException {
            if (failed) {
                throw new SQLException("", "", 1040);
            }
            return super.executeQuery(stmt, sql);
        }

        public Connection connect(String url, Properties info) throws SQLException {
            while (failed) {
                try {
                    Thread.sleep(1);
                } catch (InterruptedException e) {
                    throw new SQLException(e.getMessage(), e);
                }
            }
            return super.connect(url, info);
        }
    };
    dataSource = new DruidDataSource();
    dataSource.setUrl("jdbc:mock:xxx");
    dataSource.setTestOnBorrow(false);
    dataSource.setDriver(driver);
    dataSource.setDbType("mysql");
    dataSource.setMinIdle(1);
    dataSource.setMaxActive(1);
    dataSource.setFilters("log4j");
    dataSource.setExceptionSorter(new MySqlExceptionSorter());
}
Also used : MockDriver(com.alibaba.druid.mock.MockDriver) SQLException(java.sql.SQLException) MySqlExceptionSorter(com.alibaba.druid.pool.vendor.MySqlExceptionSorter) ResultSet(java.sql.ResultSet) Connection(java.sql.Connection) Properties(java.util.Properties) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) MockStatementBase(com.alibaba.druid.mock.MockStatementBase)

Example 2 with MySqlExceptionSorter

use of com.alibaba.druid.pool.vendor.MySqlExceptionSorter in project druid by alibaba.

the class MySqlExceptionSorterTest_oceanbase method test_true_1.

public void test_true_1() throws Exception {
    MySqlExceptionSorter sorter = new MySqlExceptionSorter();
    Assert.assertFalse(sorter.isExceptionFatal(new SQLException("", "", -10000)));
}
Also used : MySqlExceptionSorter(com.alibaba.druid.pool.vendor.MySqlExceptionSorter) SQLException(java.sql.SQLException)

Example 3 with MySqlExceptionSorter

use of com.alibaba.druid.pool.vendor.MySqlExceptionSorter in project druid by alibaba.

the class MySqlExceptionSorterTest method test_false_1.

public void test_false_1() throws Exception {
    MySqlExceptionSorter sorter = new MySqlExceptionSorter();
    Assert.assertTrue(sorter.isExceptionFatal(new SQLException("", "", -8000)));
    Assert.assertFalse(sorter.isExceptionFatal(new SQLException("", "", -9100)));
}
Also used : MySqlExceptionSorter(com.alibaba.druid.pool.vendor.MySqlExceptionSorter) SQLException(java.sql.SQLException)

Example 4 with MySqlExceptionSorter

use of com.alibaba.druid.pool.vendor.MySqlExceptionSorter in project druid by alibaba.

the class MySqlExceptionSorterTest method test_false_2.

public void test_false_2() throws Exception {
    MySqlExceptionSorter sorter = new MySqlExceptionSorter();
    Assert.assertFalse(sorter.isExceptionFatal(new SQLException("", null, 0)));
}
Also used : MySqlExceptionSorter(com.alibaba.druid.pool.vendor.MySqlExceptionSorter) SQLException(java.sql.SQLException)

Example 5 with MySqlExceptionSorter

use of com.alibaba.druid.pool.vendor.MySqlExceptionSorter in project druid by alibaba.

the class MySqlExceptionSorterTest method test_true_1.

public void test_true_1() throws Exception {
    MySqlExceptionSorter sorter = new MySqlExceptionSorter();
    Assert.assertTrue(sorter.isExceptionFatal(new SQLException("", "", 1042)));
}
Also used : MySqlExceptionSorter(com.alibaba.druid.pool.vendor.MySqlExceptionSorter) SQLException(java.sql.SQLException)

Aggregations

MySqlExceptionSorter (com.alibaba.druid.pool.vendor.MySqlExceptionSorter)13 SQLException (java.sql.SQLException)13 MockDriver (com.alibaba.druid.mock.MockDriver)1 MockStatementBase (com.alibaba.druid.mock.MockStatementBase)1 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)1 Constructor (java.lang.reflect.Constructor)1 SocketTimeoutException (java.net.SocketTimeoutException)1 Connection (java.sql.Connection)1 ResultSet (java.sql.ResultSet)1 Properties (java.util.Properties)1