Conversion exception when calling a stored procedure with a datetime in-out parameter while setting a String value #2436
Labels
Bug
A bug in the driver. A high priority item that one can expect to be addressed quickly.
Projects
Driver version
12.6.1 and 12.6.2
SQL Server version
Microsoft SQL Server 2022 (RTM-CU12-GDR) (KB5036343) - 16.0.4120.1 (X64) Mar 18 2024 12:02:14 Copyright (C) 2022 Microsoft Corporation Developer Edition (64-bit) on Windows 10 Pro 10.0 (Build 22631: )
Client Operating System
Windows 11
JAVA/JVM version
17.0.10+7
Table schema
Problem description
After using the Microsoft SQL Server JDBC driver for years without issue, we hit a blocking regression with v12.6.1 and v12.6.2. In short, when calling a stored procedure with a datetime in-out parameter and setting a String value, retrieving the out value now throws a conversion exception. The failure seems to hinge on using setObject() with Timestamp.toString() instead of a Timestamp object, even though Types.TIMESTAMP is specified in setObject() and the parameter is typed as datetime in the stored procedure.
We're setting the value to Timestamp.toString() because that's the recommended workaround mentioned on this page https://learn.microsoft.com/en-us/sql/connect/jdbc/using-basic-data-types?view=sql-server-ver16 (footnote 3). The code that's failing in our system is a very general-purpose ETL that works on client-provided tables, so we don't have the ability to change column types to datetime2.
If there's another workaround, we're all ears. And if more information is needed, please let us know.
Expected behavior
These are the results of the example code below when using v12.4.2.0
Actual behavior
These are the results of the example code below when using v12.6.1 or v12.6.2
Error message/stack trace
Any other details that can be helpful
A simple, complete class that reproduces the problem (along with the simple stored procedure above) is below.
JDBC trace logs
Provide the JDBC driver trace logs. Instructions can be found here: https://docs.microsoft.com/sql/connect/jdbc/tracing-driver-operation
The text was updated successfully, but these errors were encountered: