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

Exception chaining doesn't work in JDBC driver #2115

Closed
akley opened this issue Apr 28, 2023 · 10 comments · Fixed by #2251
Closed

Exception chaining doesn't work in JDBC driver #2115

akley opened this issue Apr 28, 2023 · 10 comments · Fixed by #2251
Labels
Backlog The topic in question has been recognized and added to development backlog Documentation Pull requests that update documentation Enhancement An enhancement to the driver. Lower priority than bugs.

Comments

@akley
Copy link

akley commented Apr 28, 2023

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

@lilgreenbird lilgreenbird changed the title Exception chaning doesn't work in JDBC driver Exception chaining doesn't work in JDBC driver Apr 29, 2023
@lilgreenbird
Copy link
Contributor

hi @akley

Thanks for bringing this to our attention, you are correct looks like this is currently not supported I have added this as an feature enhancement to be considered when we do planning for the next semester.

I do notice our docs erroneously includes these unsupported APIs I will look into getting this updated, thanks.

@lilgreenbird lilgreenbird added Documentation Pull requests that update documentation Backlog The topic in question has been recognized and added to development backlog Enhancement An enhancement to the driver. Lower priority than bugs. labels Apr 29, 2023
@akley
Copy link
Author

akley commented May 4, 2023

Hi @lilgreenbird

maybe it would be a good idea for you to take look to the jTDS implementation (https://jtds.sourceforge.net). There it is possible to handle chained exceptions.
In net.sourceforge.jtds.jdbc.JtdsStatement and SQLDiagnostic the java.sql.SQLException.setNextException method will be called to chain the incoming exceptions.

Best regards
Alex

@lilgreenbird
Copy link
Contributor

docs update merged

@akley
Copy link
Author

akley commented May 5, 2023

getNextExcption() has been removed from the api doc, but the example still shows: "se = se.getNextException();"
Please remove this also from documentations.

Cheers
Alex

@Jeffery-Wasty
Copy link
Contributor

Hi @akley,

Thanks for noticing this. We've corrected that as well.

@akley
Copy link
Author

akley commented Jul 5, 2023

Hi Jeffery, do you already have an idea when you will deliver the missing implementation?
I just saw that you have deposited a 12.3 preview version at maven central.

Cheers
Alex

@Jeffery-Wasty
Copy link
Contributor

Jeffery-Wasty commented Jul 5, 2023

As mentioned above we'll take a look at this during our semester planning, which is around Aug/Sep. We'll have a bit more of an idea of the time frame for this enhancement following that meeting. You can also submit a response to our survey which is also taken into consideration when planning for the upcoming semester.

@akley
Copy link
Author

akley commented Feb 12, 2024

Any updates on this issue?

@tkyc
Copy link
Contributor

tkyc commented Feb 13, 2024

@akley I believe this PR #2251 covers the issue. Currently we're reviewing it. It should likely make it into the next preview.

@akley
Copy link
Author

akley commented Feb 14, 2024

@tkyc Thanks a lot! Hope this fixes the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backlog The topic in question has been recognized and added to development backlog Documentation Pull requests that update documentation Enhancement An enhancement to the driver. Lower priority than bugs.
Projects
Status: Closed Issues
Development

Successfully merging a pull request may close this issue.

4 participants