diff --git a/src/main/java/com/alibaba/druid/pool/DruidDataSource.java b/src/main/java/com/alibaba/druid/pool/DruidDataSource.java index 4213e5b299..68b6f7e9ea 100644 --- a/src/main/java/com/alibaba/druid/pool/DruidDataSource.java +++ b/src/main/java/com/alibaba/druid/pool/DruidDataSource.java @@ -915,7 +915,7 @@ public class DruidDataSource extends DruidAbstractDataSource } else if (realDriverClassName.equals("com.sybase.jdbc2.jdbc.SybDriver")) { this.exceptionSorter = new SybaseExceptionSorter(); - } else if (realDriverClassName.equals("org.postgresql.Driver")) { + } else if (realDriverClassName.equals(JdbcConstants.POSTGRESQL_DRIVER)) { this.exceptionSorter = new PGExceptionSorter(); } else if (realDriverClassName.equals("com.alibaba.druid.mock.MockDriver")) { diff --git a/src/test/java/com/alibaba/druid/bvt/pool/vendor/PGExceptionSorterTest.java b/src/test/java/com/alibaba/druid/bvt/pool/vendor/PGExceptionSorterTest.java new file mode 100644 index 0000000000..fd5031d2c1 --- /dev/null +++ b/src/test/java/com/alibaba/druid/bvt/pool/vendor/PGExceptionSorterTest.java @@ -0,0 +1,21 @@ +package com.alibaba.druid.bvt.pool.vendor; + +import org.junit.Assert; +import org.postgresql.util.GT; +import org.postgresql.util.PSQLException; +import org.postgresql.util.PSQLState; + +import junit.framework.TestCase; + +import com.alibaba.druid.pool.vendor.PGExceptionSorter; + +public class PGExceptionSorterTest extends TestCase { + + public void test_pg() throws Exception { + PGExceptionSorter exSorter = new PGExceptionSorter(); + + PSQLException ex = new PSQLException(GT.tr("Expected an EOF from server, got: {0}", new Integer(0)), + PSQLState.COMMUNICATION_ERROR); + Assert.assertTrue(exSorter.isExceptionFatal(ex)); + } +}