Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLServerException provides null SQLState and 0 error code #2015

Closed
labkey-adam opened this issue Dec 23, 2022 · 7 comments
Closed

SQLServerException provides null SQLState and 0 error code #2015

labkey-adam opened this issue Dec 23, 2022 · 7 comments
Assignees
Labels
Bug A bug in the driver. A high priority item that one can expect to be addressed quickly.
Projects
Milestone

Comments

@labkey-adam
Copy link

Driver version

12.1.0.jre11-preview

SQL Server version

Microsoft SQL Server 2022 (RC1) - 16.0.950.9 (X64)

Client Operating System

Windows 10

JAVA/JVM version

OpenJDK 64-Bit Server VM Temurin-17.0.5+8 (build 17.0.5+8, mixed mode, sharing)

Table schema

N/A

Problem description

SQLExceptions thrown by the 12.1.0 preview driver no longer include valid SQLState or error code values. This appears to be a significant regression since many applications rely on these values for proper exception handling. We happen to use Spring SQLExceptionTranslators to translate SQLExceptions into standard Spring runtime exceptions (DataIntegrityViolationException and DeadlockLoserDataAccessException in the below examples) and the translations are now failing because these return values are incorrect.

A couple examples that our test suite flagged are provided below, but this is likely not an exhaustive list.

Expected behavior

In previous versions (11.2.1, 10.2.1), calling getSQLState() returned a valid SQL state code and getErrorCode() returned a valid vendor code. Two examples:

  • Divide by zero ("com.microsoft.sqlserver.jdbc.SQLServerException: An error occurred during the current command (Done status 0). Divide by zero error encountered."):
    • e.getSQLState() returned "S0001"
    • e.getErrorCode() returned 8134
  • Deadlock loser ("com.microsoft.sqlserver.jdbc.SQLServerException: An error occurred during the current command (Done status 0). Transaction (Process ID 66) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction."):
    • e.getSQLState() returned "40001"
    • e.getErrorCode() returned 1205

Actual behavior

With the preview driver, the above exceptions no longer provide valid values. In both cases:

  • e.getSQLState() returns null
  • e.getErrorCode() returns 0

Let me know if you need more information to resolve this.

@tkyc
Copy link
Member

tkyc commented Dec 23, 2022

Hey @labkey-adam, thanks informing us. I'm able to reproduce the issue. We'll look into the bug.

@Jeffery-Wasty
Copy link
Member

In the meantime, are you able to use the previous stable version, 11.2.1?

@Jeffery-Wasty Jeffery-Wasty self-assigned this Dec 23, 2022
@Jeffery-Wasty Jeffery-Wasty added the Under Investigation Used for issues under investigation label Dec 23, 2022
@Jeffery-Wasty Jeffery-Wasty added this to Under Investigation in MSSQL JDBC via automation Dec 23, 2022
@labkey-adam
Copy link
Author

@tkyc and @Jeffery-Wasty Thanks for the quick responses. Yes, we are able to use 11.2.1, no problem. We appreciate your efforts!

@Jeffery-Wasty Jeffery-Wasty assigned tkyc and unassigned Jeffery-Wasty Dec 23, 2022
@lilgreenbird lilgreenbird added Bug A bug in the driver. A high priority item that one can expect to be addressed quickly. and removed Under Investigation Used for issues under investigation labels Dec 23, 2022
@lilgreenbird lilgreenbird added this to the 12.2.0 milestone Jan 12, 2023
@tkyc
Copy link
Member

tkyc commented Jan 13, 2023

Hi, we just released a 11.2.3 version of the driver with the fix.

@labkey-adam
Copy link
Author

That's great, @tkyc ! Is there a plan to release a new 12.x preview version?

@Jeffery-Wasty
Copy link
Member

Hi @labkey-adam,

The 12.2.0 release is planned for the end of this month, Jan 31st.

@lilgreenbird
Copy link
Member

fixed in #2018

MSSQL JDBC automation moved this from Under Investigation to Closed Issues Jan 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in the driver. A high priority item that one can expect to be addressed quickly.
Projects
MSSQL JDBC
  
Closed Issues
Development

No branches or pull requests

4 participants