-
Notifications
You must be signed in to change notification settings - Fork 579
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
Conversation
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.
Thank you for your pull request and welcome to our community! To contribute, please sign the Oracle Contributor Agreement (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. |
fix for #8344 |
Update copyright
Thank you for signing the OCA. |
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.
Looks good
Summary:
This PR addresses an issue in the JDBC parameter binding logic where
null
values were incorrectly being set withTypes.VARCHAR
SQL type. This behavior lead to SQL exceptions when insertingnull
into non-VARCHAR
columns in a database. The proposed change ensures thatnull
values are set withTypes.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 ofTypes.VARCHAR
fornull
parameters leads to type mismatch errors for columns of types other thanVARCHAR
. For example, insertingnull
into aNUMERIC
column results in aPSQLException
with a message indicating a type mismatch.Proposed Solution:
The fix involves changing the SQL type for
null
parameters fromTypes.VARCHAR
toTypes.NULL
in thesetParameter
method of the JDBC parameter handling logic. This change allows the JDBC driver to determine the correct type for thenull
value based on the context of the column it is being inserted into, thus preventing type mismatch errors.