Skip to content

[BUG] Driver returns SQL State longer than 5 characters #956

@axelfontaine

Description

@axelfontaine

Driver version

7.2.1

SQL Server version

N/A

Client Operating System

N/A

JAVA/JVM version

1.8, 11

Table schema

N/A

Problem description

  1. Expected behaviour: when an error occurs the driver should throw a SQL exception with a 5 character SQL state
  2. Actual behaviour: SQL state is sometimes 6 characters due to this code: https://github.com/Microsoft/mssql-jdbc/blob/9c5cc97f661fe14de11df6be16c8acbc3379d1ff/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerException.java#L364

The EXECUTE AS USER = 'DOMAIN/USER' can for example result in SQL state S00011 (6 chars!) and the message Could not obtain information about Windows NT group/user '[USER_NAME]', error code 0x4bc.

This was reported to us by a customer: See flyway/flyway#2275

We believe the driver's behavior is incorrect in this case as it violates the SQLSTATE standard.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in the driver. A high priority item that one can expect to be addressed quickly.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions