diff --git a/src/main/java/com/alibaba/druid/VERSION.java b/src/main/java/com/alibaba/druid/VERSION.java index 8501c917da..e4ce36146b 100644 --- a/src/main/java/com/alibaba/druid/VERSION.java +++ b/src/main/java/com/alibaba/druid/VERSION.java @@ -19,7 +19,7 @@ public final class VERSION { public final static int MajorVersion = 0; public final static int MinorVersion = 2; - public final static int RevisionVersion = 20; + public final static int RevisionVersion = 21; public static String getVersionNumber() { return VERSION.MajorVersion + "." + VERSION.MinorVersion + "." + VERSION.RevisionVersion; diff --git a/src/main/java/com/alibaba/druid/pool/vendor/MySqlExceptionSorter.java b/src/main/java/com/alibaba/druid/pool/vendor/MySqlExceptionSorter.java index 5dc7374e60..37a98bdfcc 100644 --- a/src/main/java/com/alibaba/druid/pool/vendor/MySqlExceptionSorter.java +++ b/src/main/java/com/alibaba/druid/pool/vendor/MySqlExceptionSorter.java @@ -58,6 +58,10 @@ public class MySqlExceptionSorter implements ExceptionSorter { default: break; } + + if (errorCode >= -10000 && errorCode <= -9000) { + return true; + } return false; } diff --git a/src/test/java/com/alibaba/druid/bvt/pool/vendor/MySqlExceptionSorterTest.java b/src/test/java/com/alibaba/druid/bvt/pool/vendor/MySqlExceptionSorterTest.java new file mode 100644 index 0000000000..222c3c6ffc --- /dev/null +++ b/src/test/java/com/alibaba/druid/bvt/pool/vendor/MySqlExceptionSorterTest.java @@ -0,0 +1,42 @@ +package com.alibaba.druid.bvt.pool.vendor; + +import java.sql.SQLException; + +import junit.framework.TestCase; + +import org.junit.Assert; + +import com.alibaba.druid.pool.vendor.MySqlExceptionSorter; + + +public class MySqlExceptionSorterTest extends TestCase { + public void test_true() throws Exception { + MySqlExceptionSorter sorter = new MySqlExceptionSorter(); + Assert.assertTrue(sorter.isExceptionFatal(new SQLException("", "", 1040))); + } + + public void test_true_1() throws Exception { + MySqlExceptionSorter sorter = new MySqlExceptionSorter(); + Assert.assertTrue(sorter.isExceptionFatal(new SQLException("", "", 1042))); + } + + public void test_true_2() throws Exception { + MySqlExceptionSorter sorter = new MySqlExceptionSorter(); + Assert.assertTrue(sorter.isExceptionFatal(new SQLException("", "08xx", 0))); + } + + public void test_false_2() throws Exception { + MySqlExceptionSorter sorter = new MySqlExceptionSorter(); + Assert.assertFalse(sorter.isExceptionFatal(new SQLException("", null, 0))); + } + + public void test_false() throws Exception { + MySqlExceptionSorter sorter = new MySqlExceptionSorter(); + Assert.assertFalse(sorter.isExceptionFatal(new SQLException("", "", -10001))); + } + + public void test_false_1() throws Exception { + MySqlExceptionSorter sorter = new MySqlExceptionSorter(); + Assert.assertFalse(sorter.isExceptionFatal(new SQLException("", "", -8000))); + } +} diff --git a/src/test/java/com/alibaba/druid/bvt/pool/vendor/MySqlExceptionSorterTest_oceanbase.java b/src/test/java/com/alibaba/druid/bvt/pool/vendor/MySqlExceptionSorterTest_oceanbase.java new file mode 100644 index 0000000000..04bd235ed3 --- /dev/null +++ b/src/test/java/com/alibaba/druid/bvt/pool/vendor/MySqlExceptionSorterTest_oceanbase.java @@ -0,0 +1,32 @@ +package com.alibaba.druid.bvt.pool.vendor; + +import java.sql.SQLException; + +import junit.framework.TestCase; + +import org.junit.Assert; + +import com.alibaba.druid.pool.vendor.MySqlExceptionSorter; + + +public class MySqlExceptionSorterTest_oceanbase extends TestCase { + public void test_true() throws Exception { + MySqlExceptionSorter sorter = new MySqlExceptionSorter(); + Assert.assertTrue(sorter.isExceptionFatal(new SQLException("", "", -9000))); + } + + public void test_true_1() throws Exception { + MySqlExceptionSorter sorter = new MySqlExceptionSorter(); + Assert.assertTrue(sorter.isExceptionFatal(new SQLException("", "", -10000))); + } + + public void test_false() throws Exception { + MySqlExceptionSorter sorter = new MySqlExceptionSorter(); + Assert.assertFalse(sorter.isExceptionFatal(new SQLException("", "", -10001))); + } + + public void test_false_1() throws Exception { + MySqlExceptionSorter sorter = new MySqlExceptionSorter(); + Assert.assertFalse(sorter.isExceptionFatal(new SQLException("", "", -8000))); + } +}