Skip to content

jdbc: support categorized exceptions and SQLSTATE codes #119

Closed

Description

@Totktonada

Return sqlStateSQL or sqlStateSQL99 (they are equal) from
DatabaseMetaData.getSQLStateType(). Now the value is 0, which is not correct.

Use SQLSTATE codes in SQLException where appropriate.

Use categorized SQL exceptions where possible:

  • SQLNonTransientException
  • SQLTransientException
  • SQLRecoverableException

Consider also using of BatchUpdateException and SQLClientInfoException.

Test all this new stuff.

See also: https://docs.oracle.com/javase/tutorial/jdbc/basics/sqlexception.html

This issue is mostly optional (AFAIU), but DatabaseMetaData.getSQLStateType() should provide a correct value.

Activity

  1. added this to the JDBC MVP milestone on Jan 23, 2019
  2. Totktonada commented on Oct 17, 2019

    @Totktonada
    Author

    We use sqlStateSQL codes now, but DatabaseMetaData.getSQLStateType() still returns 0. I think we should return sqlStateSQL here and close this issue.

    As I see from other JDBC implementations (mysql-connector-j, mariadb-connector-j, pgjdbc), it seems we don't obligated to set an sqlstate code for each thrown SQLException.

    See also https://bugs.mysql.com/bug.php?id=3520

  3. added a commit that references this issue on Dec 5, 2019
    4ae9f91
  4. added a commit that references this issue on Apr 27, 2020
    545fd9a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions