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

Return reasonable values from java.sql.DatabaseMetaData API methods. #1417

Closed
wants to merge 3 commits into from

Conversation

theshoeshiner
Copy link

Overview

SNOW-XXXXX

External contributors - please answer these questions before submitting a pull request. Thanks!

Please answer these questions before submitting your pull requests. Thanks!

  1. What GitHub issue is this PR addressing? Make sure that there is an accompanying issue to your PR.

    Fixes Should not throw exceptions from certain methods in net.snowflake.client.jdbc.SnowflakeDatabaseMetaData #1416

  2. Fill out the following pre-review checklist:

    • I am adding a new automated test(s) to verify correctness of my new code
    • I am adding new logging messages
    • I am modifying authorization mechanisms
    • I am adding new credentials
    • I am modifying OCSP code
    • I am adding a new dependency
  3. Please describe how your code solves the related issue.

The reasons for this is detailed in the issue description

The net.snowflake.client.jdbc.SnowflakeDatabaseMetaData class throws SnowflakeLoggedFeatureNotSupportedException from certain JDBC methods. Throwing those exceptions causes cascading failures in frameworks that depend on JDBC drivers (e.g. Hibernate). Exceptions should only be thrown from those methods in the case of database access errors (per the java.sql.DatabaseMetaData API). For most of those methods a reasonable value should be returned and exceptions should only be thrown if/when unsupported features are used as opposed to throwing them in methods which simply describe the driver.

The two methods that cause the currently observed failure are:

net.snowflake.client.jdbc.SnowflakeDatabaseMetaData.getSQLStateType()
net.snowflake.client.jdbc.SnowflakeDatabaseMetaData.locatorsUpdateCopy()

Retuning the constant java.sql.DatabaseMetaData.sqlStateSQL from getSQLStateType() appears to work fine, and returning false from locatorsUpdateCopy() works as well.

The same principle should be followed for any other java.sql.DatabaseMetaData methods which describe features, to prevent similar issues in other frameworks.

Pre-review checklist

  • This change has passed precommit
  • I have reviewed code coverage report for my PR in (Sonarqube)

@theshoeshiner theshoeshiner requested a review from a team as a code owner June 13, 2023 13:32
@github-actions github-actions bot locked and limited conversation to collaborators Oct 17, 2023
@sfc-gh-igarish
Copy link
Collaborator

already fix as part of other PR. Please check latest code.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Should not throw exceptions from certain methods in net.snowflake.client.jdbc.SnowflakeDatabaseMetaData
2 participants