The SQLErrorCodeSQLExceptionTranslator class does a binary search on the SQLErrorCodes of each category. But binary search expects these to be in ascending order.
Since these error-codes are stored in String[], they need to be in an "alphanumeric" sorted order in the sql-error-codes.xml file.
Following are some examples of this not being the case:
In release 2.5.6 for DB=Sybase the following codes are defined:
<property name="transientDataAccessResourceCodes">
<value>921,1105</value>
</property>
These are in ascending order numerically but since SQLErrorCodeSQLExceptionTranslator does a binary search on String[] this is not ascending alphanumerically
The following break in older version 2.5.5 and older":
<property name="dataIntegrityViolationCodes">
<value>423,511,515,530,547,2601,2615,2714</value>
</property>
There are other such breaks as well in the file.
Instead of fixing the config file to keep the codes sorted alphanumerically, may I suggest that the SQLErrorCodes actually be explicitly sorted on load? In case a user overrides the the sql-error-codes.xml it can easily lead to bugs if the file is not maintained alphanumerically sorted.
A clarification about the above the description:
The example of "dataIntegrityViolationCodes" given above does not hold true. This does infact get sorted. But there are others which dont for eg:
dataAccessResourceFailureCodes (Although the sql-error-codes.xml file is sorted correctly in this case, users overriding it will still face the problem)
transientDataAccessResourceCodes
invalidResultSetAccessCodes, etc.
Thanks,
Abhi