What are all the possible values for SQLException.getSQLState?

前端 未结 4 1884
滥情空心
滥情空心 2021-02-05 09:14

SQLException.getSQLState retrieves the SQLState for the SQLException object. What are all the possible values that can be returned by this

4条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-05 09:41

    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.

提交回复
热议问题