With the following I was able to get the keys and values with some regexing, but not very database independant but does work with FrontBase. It relies on the sql exception message predictably containing the key and value information. Wether other databases do I don't know but you may get some mileage here.

String FRONTBASE_UNIQUE_CONSTRAINT_KV_PATTERN ="\\(UNIQUE,\\s[A-Z]+\ \._[C]\\d+\\(([A-Z]+)='(.+)'\\)" JDBCAdaptorException e = ((EOAdaptorOperation) someEOGeneralAdaptorExceptionCausedByUniqueConstraint .userInfo ().objectForKey ("EOFailedAdaptorOperationKey")).exception().sqlException();
Pattern p = Pattern.compile(FRONTBASE_UNIQUE_CONSTRAINT_KV_PATTERN);
Matcher m = p.matcher(e.sqlException().getMessage());
if (m.find() && m.groupCount()==2){
        String key = m.group(1);
        String value = m.group(2);
String method = "UniqueContraintViolation" + ERXStringUtilities.capitalize(key.toLowerCase()); return ERXValidationFactory .defaultFactory ().createCustomException((ERXGenericRecord)databaseFailedOp.object(), key, value, method);
}

Happy 4th of July (was wondering why it was quiet here today)

Paul S
Treasuremytext.com


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to