Skip to content

Exception chaining doesn't work in JDBC driver #2115

@akley

Description

@akley

Driver Version

11.2.3.jre8, but it doesn't work with any version, wether JAVA or JAVA 11

SQL Server Version

Microsoft SQL Server 2019 (RTM-CU20) (KB5024276) - 15.0.4312.2 (X64) Apr 1 2023 12:10:46 Copyright (C) 2019 Microsoft Corporation Standard Edition (64-bit) on Windows Server 2022 Standard 10.0 (Build 20348: ) (Hypervisor)

Problem description

  • plain procedure call via Statement.exeute()
  • the procedure P1 calls another procedure P2
  • the inner procedure P2 raise an error with 'raiserror('P2 - inner exception text', 16, 1) with nowait' and return 1
  • the outer procedure P1 evaluate the return value and raise an error again 'raiserror('P1 - P2 raised an error', 16, 1) with nowait'
  • in the catch block of the jdbc call only the first exception which was transported to the client ("P2 - inner exception text") will be shown. When I'll try e.getNextException() the returned object is NULL. Why?

It seems like the getNextException() and setNextException() methods are not used in SQLServerException that extend SQLException .

When I inspect the raised exception, the property 'next' of SQLException is NULL

All other calls are working fine!

Btw: in SQL Management Studion, both exceptions are returned to the client, as I excpected.

p1.txt
p2.txt

Test_Chained_Exceptions.java.txt

It would help me a lot if you could give me an answer here. Thanks very much!
Best Regards
Alex

Metadata

Metadata

Assignees

Labels

BacklogThe topic in question has been recognized and added to development backlogDocumentationPull requests that update documentationEnhancementAn enhancement to the driver. Lower priority than bugs.Under ReviewUsed for pull requests under review

Type

No type

Projects

Status

Under Peer Review

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions