Support for Microsoft SQL Server driver version 4 and above [SPR-13772] #18346
Labels
in: data
Issues in data modules (jdbc, orm, oxm, tx)
status: backported
An issue that has been backported to maintenance branches
type: enhancement
A general enhancement
Milestone
Gareth Moorst opened SPR-13772 and commented
Using JdbcTemplate, trying to insert NULL into a DATE column using the Microsoft SQL Server driver no longer works in versions 4 and above of the JDBC driver.
It still works in driver version 3.
To be clear, the driver behaviour hasn't changed from version 3 to 4. The driver requires slightly different calling code to some other JDBC drivers - instead of using
PreparedStatement.setNull(int index, int type)
,it needs
PreparedStatement.setObject(int index, Object value)
, withvalue = null
.There is a workaround in
org.springframework.jdbc.core.StatementCreatorUtils.java:285
that checks if the driver name starts with "Microsoft SQL Server" and uses setObject instead of setNull.Unfortunately, the driver name has changed in versions 4 and above.
Instead of being "Microsoft SQL Server JDBC Driver 3.0" it is now "Microsoft JDBC Driver 4.0 for SQL Server".
Here is test code that reproduces the problem (it works with driver version 3, but not 4):
Affects: 3.2.15, 4.1.8, 4.2.3
Backported to: 4.1.9, 3.2.16
The text was updated successfully, but these errors were encountered: