SQLException.getSQLState
retrieves the SQLState
for the SQLException
object. What are all the possible values that can be returned by this
This is to some degree JDBC driver-dependent. There do seem to be standard values, plus some proprietary values.
As a guide to what's possible, Spring's JDBC layer includes SQL error code and state translation. It provides a SQLState translator which gives rather vague exception translation, as well as a SQLErrorCode translator which is much more fine-grained, using known proprietary error codes.
If you can't use Spring, then download the source code, and extract the sql-error-codes.xml
file, which contains the mapping from codes to exception types.