improved ExceptionSorter.

This commit is contained in:
wenshao
2017-04-18 15:49:54 +08:00
parent 85aeca86ec
commit 9e80c23b7b
6 changed files with 31 additions and 0 deletions
@@ -16,6 +16,7 @@
package com.alibaba.druid.pool.vendor;
import java.sql.SQLException;
import java.sql.SQLRecoverableException;
import java.util.Properties;
import com.alibaba.druid.pool.ExceptionSorter;
@@ -24,6 +25,10 @@ public class DB2ExceptionSorter implements ExceptionSorter {
@Override
public boolean isExceptionFatal(SQLException e) {
if (e instanceof SQLRecoverableException) {
return true;
}
String sqlState = e.getSQLState();
if (sqlState != null && sqlState.startsWith("08")) { // Connection Exception
return true;
@@ -17,6 +17,7 @@ package com.alibaba.druid.pool.vendor;
import java.io.Serializable;
import java.sql.SQLException;
import java.sql.SQLRecoverableException;
import java.util.Properties;
import com.alibaba.druid.pool.ExceptionSorter;
@@ -26,6 +27,10 @@ public class InformixExceptionSorter implements ExceptionSorter, Serializable {
private static final long serialVersionUID = -5175884111768095263L;
public boolean isExceptionFatal(SQLException e) {
if (e instanceof SQLRecoverableException) {
return true;
}
switch (e.getErrorCode()) {
case -710: // Table has been dropped, altered or renamed JBAS-3120
case -79716: // System or internal error
@@ -18,12 +18,17 @@ package com.alibaba.druid.pool.vendor;
import com.alibaba.druid.pool.ExceptionSorter;
import java.sql.SQLException;
import java.sql.SQLRecoverableException;
import java.util.Properties;
public class MySqlExceptionSorter implements ExceptionSorter {
@Override
public boolean isExceptionFatal(SQLException e) {
if (e instanceof SQLRecoverableException) {
return true;
}
final String sqlState = e.getSQLState();
final int errorCode = e.getErrorCode();
@@ -21,6 +21,7 @@ import com.alibaba.druid.support.logging.LogFactory;
import java.io.Serializable;
import java.sql.SQLException;
import java.sql.SQLRecoverableException;
import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
@@ -66,6 +67,10 @@ public class OracleExceptionSorter implements ExceptionSorter, Serializable {
}
public boolean isExceptionFatal(final SQLException e) {
if (e instanceof SQLRecoverableException) {
return true;
}
final int error_code = Math.abs(e.getErrorCode()); // I can't remember if the errors are negative or positive.
switch (error_code) {
@@ -110,6 +115,7 @@ public class OracleExceptionSorter implements ExceptionSorter, Serializable {
case 17001: // Internal Error
case 17002: // Io exception
case 17008: // Closed Connection
case 17009: // Closed Statement
case 17024: // No data read
case 17089: // internal error
case 17409: // invalid buffer length
@@ -16,6 +16,7 @@
package com.alibaba.druid.pool.vendor;
import java.sql.SQLException;
import java.sql.SQLRecoverableException;
import java.util.Properties;
import com.alibaba.druid.pool.ExceptionSorter;
@@ -24,6 +25,10 @@ public class PGExceptionSorter implements ExceptionSorter {
@Override
public boolean isExceptionFatal(SQLException e) {
if (e instanceof SQLRecoverableException) {
return true;
}
String sqlState = e.getSQLState();
if (sqlState == null) {
return false;
@@ -19,6 +19,7 @@ import com.alibaba.druid.pool.ExceptionSorter;
import java.io.Serializable;
import java.sql.SQLException;
import java.sql.SQLRecoverableException;
import java.util.Properties;
public class SybaseExceptionSorter implements ExceptionSorter, Serializable {
@@ -30,6 +31,10 @@ public class SybaseExceptionSorter implements ExceptionSorter, Serializable {
}
public boolean isExceptionFatal(SQLException e) {
if (e instanceof SQLRecoverableException) {
return true;
}
boolean result = false;
String errorText = e.getMessage();