Retain error information in SQLServerPreparedStatement.getMetaData exceptions#1430
Merged
ulvii merged 1 commit intomicrosoft:devfrom Oct 13, 2020
Merged
Conversation
…ceptions
Fixes a bug in SQLServerPreparedStatement.buildExecuteMetaData which
caused the SqlState as returned from the server error to be discarded in
thrown exceptions. The SqlState information is useful for application
level error handling.
No tests are provided, as I can't get the test harness to run in my
local environment. However, here are steps to reproduce the 'bad' exception
with no included SqlState:
```java
Connection conn = null; // Fill in with SqlServer connection.
conn.prepareStatement("s");
conn.getMetaData(); // Throws exception without SqlState.
```
ulvii
reviewed
Sep 28, 2020
|
|
||
| @Override | ||
| public final java.sql.ResultSetMetaData getMetaData() throws SQLServerException { | ||
| public final java.sql.ResultSetMetaData getMetaData() throws SQLServerException, SQLTimeoutException { |
Contributor
There was a problem hiding this comment.
Is adding SQLTimeoutException necessary here? Could you explain this a bit?
Contributor
Author
There was a problem hiding this comment.
Yes. buildExecuteMetaData() previously caught and wrapped the SQLTimeoutException in another exception with less info. That's been changed so that it's no longer caught, and it gets thrown directly. The JDBC API allows for throwing this exception type, so it shouldn't be rethrown with less info.
peterbae
reviewed
Oct 1, 2020
peterbae
approved these changes
Oct 5, 2020
Contributor
|
Hi @danburkert , |
Contributor
Author
done! |
rene-ye
approved these changes
Oct 13, 2020
ulvii
approved these changes
Oct 13, 2020
lilgreenbird
approved these changes
Oct 13, 2020
Contributor
|
Thanks for the contribution @danburkert . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes a bug in SQLServerPreparedStatement.buildExecuteMetaData which
caused the SqlState as returned from the server error to be discarded in
thrown exceptions. The SqlState information is useful for application
level error handling.
No tests are provided, as I can't get the test harness to run in my
local environment. However, here are steps to reproduce the 'bad'
exception with no included SqlState: