diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/com/iciql/IciqlException.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/com/iciql/IciqlException.java b/src/com/iciql/IciqlException.java index 320604d..38c8fac 100644 --- a/src/com/iciql/IciqlException.java +++ b/src/com/iciql/IciqlException.java @@ -29,6 +29,7 @@ public class IciqlException extends RuntimeException { public static final int CODE_DUPLICATE_KEY = 2;
public static final int CODE_OBJECT_NOT_FOUND = 3;
public static final int CODE_OBJECT_ALREADY_EXISTS = 4;
+ public static final int CODE_CONSTRAINT_VIOLATION = 5;
private static final String TOKEN_UNMAPPED_FIELD = "\\? (=|\\>|\\<|\\<\\>|!=|\\>=|\\<=|LIKE|BETWEEN) \\?";
@@ -97,6 +98,9 @@ public class IciqlException extends RuntimeException { if ("23000".equals(state)) {
// MySQL duplicate primary key on insert
iciqlCode = CODE_DUPLICATE_KEY;
+ if (s.getErrorCode() == 1217) {
+ iciqlCode = CODE_CONSTRAINT_VIOLATION;
+ }
} else if ("23505".equals(state)) {
// Derby duplicate primary key on insert
iciqlCode = CODE_DUPLICATE_KEY;
@@ -139,6 +143,15 @@ public class IciqlException extends RuntimeException { } else if ("42504".equals(state)) {
// HSQL index already exists
iciqlCode = CODE_OBJECT_ALREADY_EXISTS;
+ } else if ("2BP01".equals(state)) {
+ // PostgreSQL constraint violation
+ iciqlCode = CODE_CONSTRAINT_VIOLATION;
+ } else if ("42533".equals(state)) {
+ // HSQL constraint violation
+ iciqlCode = CODE_CONSTRAINT_VIOLATION;
+ } else if ("X0Y25".equals(state)) {
+ // Derby constraint violation
+ iciqlCode = CODE_CONSTRAINT_VIOLATION;
}
}
}
|