-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Description
Issue Description:
In the Spring JDBC framework, SQL exceptions with state S0001
and vendor code 2628
for MSSQL 2019 are not properly translated to a Spring exception. This behavior differs from the previous version, MSSQL 2017, where the same exception was translated into a Data Integrity Violation exception by Spring. The issue can be reproduced by inserting a value larger in length by the max allowed value of a column.
Expected Behavior:
When encountering an SQL exception with state S0001
and vendor code 2628
message String or binary data would be truncated in table '%.*ls', column '%.*ls'. Truncated value: '%.*ls'.
from MSSQL 2019, the Spring JDBC framework should accurately translate it into a corresponding Spring exception. Instead the exception ends uncategorised (UncategorizedSQLException).
In older version of the MSSQL server (2017) the same exception is defined with:
- state:
22001
- vendor code:
8152
then when the chain of the sql exception translators are executed the state class 22
is recognised as an DataIntegrityViolationException
within the SQLErrorCodeSQLExceptionTranslator
. But in versions above 2017th the state is changed to S0001
, so none of the translators understand the exception.
Proposed solution:
Since i could not found another broken exception translation, the vendor code can be added in the sql-error-codes.xml.