Re: Java's org.postgresql.util.PSQLState is missing common PostgreSQL Error Codes

From: Jorge Solórzano <jorsol(at)gmail(dot)com>
To: David Kremer <jkorders(at)gmx(dot)com>
Cc: List <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Java's org.postgresql.util.PSQLState is missing common PostgreSQL Error Codes
Date: 2019-01-31 09:32:23
Message-ID: CA+cVU8PYS0Vvmb--SzQwocp69EFUb3P-8kHODNBy0fKYG7Xu-Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

org.postgresql.util.PSQLState it's more used for "internal" type-safe
checks of SQLState in the driver than to be used externally, it never
has a complete list of all available error codes of PostgreSQL,
SQLException returns a String representation, not the enum used in
PSQLState.

But if you need the enum you can send a PR.

On Wed, Jan 30, 2019 at 10:11 PM David Kremer <jkorders(at)gmx(dot)com> wrote:
>
> (resending to avoid HTML formatting)
>
> In my Java API server, I am using SERIALIZABLE transaction isolation mode, so I'm specially handling the error code of "40001 serialization_failure", which can occur often. I'm getting the error code String using SQLException's getSQLState() function.
>
> Therefore I was surprised to see that the Java enum org.postgresql.util.PSQLState does not include this error code.
>
> PSQLState code: https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/util/PSQLState.java
> PSQLState documentation: https://jdbc.postgresql.org/development/privateapi/org/postgresql/util/PSQLState.html[https://jdbc.postgresql.org/development/privateapi/org/postgresql/util/PSQLState.html]
>
> The 40001 serialization_failure error is listed here: https://www.postgresql.org/docs/11/errcodes-appendix.html[https://www.postgresql.org/docs/11/errcodes-appendix.html]
>
> It seems like this should be added to the pgjdbc Java enum. Is there a reason it's not in there?
>

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2019-02-01 16:54:28 [pgjdbc/pgjdbc] 94094f: Update README.md
Previous Message David Kremer 2019-01-30 21:11:30 Java's org.postgresql.util.PSQLState is missing common PostgreSQL Error Codes