Tulains Córdova
Tulains Córdova

Reputation: 2639

Postgres JDBC: Especific error code of PSQLException?

When writing java code that uses an Oracle database, one can always catch SQLException an read an specific Oracle error with e.getErrorCode(). For example, error 28001 means expired password, 28000 is blocked account, 1017 is wrong user/passsword, etc.

That way I can manage different errors the appropiate way.

But with PostgreSQL databases e.getErrorCode() always returns 0, even when catching Postgres-specific PSQLException.

The Question

Upvotes: 4

Views: 4085

Answers (1)

cjstehno
cjstehno

Reputation: 13984

Have you tried looking at getSqlState() instead? See also: http://www.postgresql.org/docs/9.3/static/errcodes-appendix.html

Upvotes: 2

Related Questions