mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved ExceptionSorter.
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user