More robust duplicate row detection.
This commit is contained in:
@@ -23,7 +23,7 @@ public class MySQLLiaison extends BaseLiaison
|
|||||||
public boolean isDuplicateRowException (SQLException sqe)
|
public boolean isDuplicateRowException (SQLException sqe)
|
||||||
{
|
{
|
||||||
String msg = sqe.getMessage();
|
String msg = sqe.getMessage();
|
||||||
return (msg != null && msg.indexOf("Duplicate entry") != -1);
|
return (sqe.getErrorCode() == 1062) || (msg != null && msg.indexOf("Duplicate entry") != -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from DatabaseLiaison
|
@Override // from DatabaseLiaison
|
||||||
|
|||||||
@@ -21,8 +21,9 @@ public class PostgreSQLLiaison extends BaseLiaison
|
|||||||
// from DatabaseLiaison
|
// from DatabaseLiaison
|
||||||
public boolean isDuplicateRowException (SQLException sqe)
|
public boolean isDuplicateRowException (SQLException sqe)
|
||||||
{
|
{
|
||||||
String msg = sqe.getMessage();
|
// PostgreSQL duplicate key error code is 23505
|
||||||
return (msg != null && msg.indexOf("duplicate key") != -1);
|
String state = sqe.getSQLState(), msg = sqe.getMessage();
|
||||||
|
return ("23505".equals(state)) || (msg != null && msg.indexOf("duplicate key") != -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// from DatabaseLiaison
|
// from DatabaseLiaison
|
||||||
|
|||||||
Reference in New Issue
Block a user