Is an enumeration of the PostgreSQL error codes provided with the JDBC driver, or do we have to create that enumeration ourselves? I can't find anything about the error codes in the JDBC documentation.
BEGIN EDIT
To clarify what I am looking for, this is my existing code:
catch (final SQLException e) {
if ("23514".equals(e.getSQLState())) {
// check_violation
}
}
I feel that most programmers would raise an eyebrow at that line, since it is neither self-documenting nor reusable. Every time a developer needs to determine the cause of the exception, (s)he will be forced to look up the error code online, and hard-code a magic number into the conditional. Instead, I would prefer to write code like:
catch (final SQLException e) {
if (PGErrors.check_violation.equals(e.getSQLState())) {
...
}
}
Does such a class enumerating the PostgreSQL error codes already exist?