From 1f06dc3216fdb327a60bb3e46a35c948c69d4b97 Mon Sep 17 00:00:00 2001 From: bartolomiew Date: Sat, 27 Oct 2012 19:31:00 +0200 Subject: return SQL error code even if uncharacterized --- src/com/iciql/IciqlException.java | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/com/iciql/IciqlException.java b/src/com/iciql/IciqlException.java index 38c8fac..b457a10 100644 --- a/src/com/iciql/IciqlException.java +++ b/src/com/iciql/IciqlException.java @@ -1,5 +1,6 @@ /* * Copyright 2011 James Moger. + * Copyright 2012 Frederic Gaillard * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +31,7 @@ public class IciqlException extends RuntimeException { 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; + public static final int CODE_UNCHARACTERIZED = 6; private static final String TOKEN_UNMAPPED_FIELD = "\\? (=|\\>|\\<|\\<\\>|!=|\\>=|\\<=|LIKE|BETWEEN) \\?"; @@ -152,6 +154,9 @@ public class IciqlException extends RuntimeException { } else if ("X0Y25".equals(state)) { // Derby constraint violation iciqlCode = CODE_CONSTRAINT_VIOLATION; + } else { + // uncharacterized SQL code, we can always rely on iciqlCode != 0 in IciqlException + iciqlCode = s.getErrorCode() == 0 ? CODE_UNCHARACTERIZED : s.getErrorCode(); } } } -- cgit v1.2.3