diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java index 6efadb88b..ba30cb0e7 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java @@ -27,6 +27,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Set; import org.apache.commons.lang.StringUtils; @@ -422,6 +423,24 @@ public class MySQLDictionary return result; } + @Override + protected int matchErrorState(Map> errorStates, SQLException ex) { + int state = super.matchErrorState(errorStates, ex); + // OPENJPA-1616 - Special case for MySQL not returning a SQLState for timeouts + if (state == StoreException.GENERAL && ex.getErrorCode() == 0 && ex.getSQLState() == null) { + // look at the nested MySQL exception for more details + SQLException sqle = ex.getNextException(); + if (sqle != null && sqle.toString().startsWith("com.mysql.jdbc.exceptions.MySQLTimeoutException")) { + if (conf != null && conf.getLockTimeout() != -1) { + state = StoreException.LOCK; + } else { + state = StoreException.QUERY; + } + } + } + return state; + } + @Override public boolean isFatalException(int subtype, SQLException ex) { if ((subtype == StoreException.LOCK && ex.getErrorCode() == 1205)