mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
add PGExceptionSorter
This commit is contained in:
@@ -69,6 +69,7 @@ import com.alibaba.druid.pool.vendor.MySqlExceptionSorter;
|
||||
import com.alibaba.druid.pool.vendor.MySqlValidConnectionChecker;
|
||||
import com.alibaba.druid.pool.vendor.OracleExceptionSorter;
|
||||
import com.alibaba.druid.pool.vendor.OracleValidConnectionChecker;
|
||||
import com.alibaba.druid.pool.vendor.PGExceptionSorter;
|
||||
import com.alibaba.druid.pool.vendor.SybaseExceptionSorter;
|
||||
import com.alibaba.druid.proxy.DruidDriver;
|
||||
import com.alibaba.druid.proxy.jdbc.DataSourceProxyConfig;
|
||||
@@ -911,6 +912,9 @@ 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")) {
|
||||
this.exceptionSorter = new PGExceptionSorter();
|
||||
|
||||
} else if (realDriverClassName.equals("com.alibaba.druid.mock.MockDriver")) {
|
||||
this.exceptionSorter = new MockExceptionSorter();
|
||||
} else if (realDriverClassName.contains("DB2")) {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.alibaba.druid.pool.vendor;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Properties;
|
||||
|
||||
import com.alibaba.druid.pool.ExceptionSorter;
|
||||
|
||||
public class PGExceptionSorter implements ExceptionSorter {
|
||||
|
||||
@Override
|
||||
public boolean isExceptionFatal(SQLException e) {
|
||||
String sqlState = e.getSQLState();
|
||||
if (sqlState == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// org.postgresql.util.PSQLState
|
||||
if (sqlState.startsWith("08")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configFromProperties(Properties properties) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user