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

Fix for #8344 - Incorrect SQL Type for null Parameters in JDBC Parameter Binding #8342

Merged
merged 3 commits into from
Feb 23, 2024

Conversation

bjcoombs
Copy link
Contributor

@bjcoombs bjcoombs commented Feb 7, 2024

Summary:

This PR addresses an issue in the JDBC parameter binding logic where null values were incorrectly being set with Types.VARCHAR SQL type. This behavior lead to SQL exceptions when inserting null into non-VARCHAR columns in a database. The proposed change ensures that null values are set with Types.NULL, allowing the JDBC driver to correctly interpret the intended type based on the column definition.

Problem Description:

When attempting to insert null values into a database using the Helidon JDBC client, the fixed SQL type of Types.VARCHAR for null parameters leads to type mismatch errors for columns of types other than VARCHAR. For example, inserting null into a NUMERIC column results in a PSQLException with a message indicating a type mismatch.

Proposed Solution:

The fix involves changing the SQL type for null parameters from Types.VARCHAR to Types.NULL in the setParameter method of the JDBC parameter handling logic. This change allows the JDBC driver to determine the correct type for the null value based on the context of the column it is being inserted into, thus preventing type mismatch errors.

This PR addresses an issue in the JDBC parameter binding logic where null values were incorrectly being set with Types.VARCHAR SQL type. This behavior could lead to SQL exceptions when inserting null into non-VARCHAR columns in a database. The proposed change ensures that null values are set with Types.NULL, allowing the JDBC driver to correctly interpret the intended type based on the column definition.

Problem Description:
When attempting to insert null values into a database using the Helidon JDBC client, the fixed SQL type of Types.VARCHAR for null parameters leads to type mismatch errors for columns of types other than VARCHAR. For example, inserting null into a NUMERIC column results in a PSQLException with a message indicating a type mismatch.

Proposed Solution:
The fix involves changing the SQL type for null parameters from Types.VARCHAR to Types.NULL in the setParameter method of the JDBC parameter handling logic. This change allows the JDBC driver to determine the correct type for the null value based on the context of the column it is being inserted into, thus preventing type mismatch errors.
Copy link

Thank you for your pull request and welcome to our community! To contribute, please sign the Oracle Contributor Agreement (OCA).
The following contributors of this PR have not signed the OCA:

To sign the OCA, please create an Oracle account and sign the OCA in Oracle's Contributor Agreement Application.

When signing the OCA, please provide your GitHub username. After signing the OCA and getting an OCA approval from Oracle, this PR will be automatically updated.

If you are an Oracle employee, please make sure that you are a member of the main Oracle GitHub organization, and your membership in this organization is public.

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Required At least one contributor does not have an approved Oracle Contributor Agreement. label Feb 7, 2024
@bjcoombs bjcoombs changed the title Fix Incorrect SQL Type for null Parameters in JDBC Parameter Binding Fix for #8344 - Incorrect SQL Type for null Parameters in JDBC Parameter Binding Feb 7, 2024
@bjcoombs
Copy link
Contributor Author

bjcoombs commented Feb 7, 2024

fix for #8344

Update copyright
Copy link

Thank you for signing the OCA.

@oracle-contributor-agreement oracle-contributor-agreement bot added OCA Verified All contributors have signed the Oracle Contributor Agreement. and removed OCA Required At least one contributor does not have an approved Oracle Contributor Agreement. labels Feb 8, 2024
Copy link
Member

@Tomas-Kraus Tomas-Kraus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@Tomas-Kraus Tomas-Kraus merged commit 0a5a494 into helidon-io:main Feb 23, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix SQL Type Mismatch Error for Null Parameters in JDBC Parameter Binding
2 participants