-
Notifications
You must be signed in to change notification settings - Fork 435
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
Retain error information in SQLServerPreparedStatement.getMetaData exceptions #1430
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. ```
@@ -1050,7 +1050,7 @@ else if (needsPrepare) | |||
} | |||
|
|||
@Override | |||
public final java.sql.ResultSetMetaData getMetaData() throws SQLServerException { | |||
public final java.sql.ResultSetMetaData getMetaData() throws SQLServerException, SQLTimeoutException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is adding SQLTimeoutException necessary here? Could you explain this a bit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java
Show resolved
Hide resolved
Hi @danburkert , |
done! |
Thanks for the contribution @danburkert . |
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: