improved postgresql support

This commit is contained in:
wenshao
2014-12-08 23:47:20 +08:00
parent aaccb63c33
commit fbb27230e1
2 changed files with 22 additions and 1 deletions
@@ -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")) {
@@ -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));
}
}