解决:sqlserver不支持LocalDateTime的问题

项目环境:springboot  2.1.4.RELEASE+mybatisplu 3.1.1 + 数据源两个mysql和sqlserver.

报错内容:

org.springframework.dao.DataIntegrityViolationException:Error attempting to get column 'open_date' from result set. 
 Cause: com.microsoft.sqlserver.jdbc.SQLServerException: The conversion to class java.time.LocalDateTime is unsupported.
; The conversion to class java.time.LocalDateTime is unsupported.; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: The conversion to class java.time.LocalDateTime is unsupported.at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:104)

今天在做多数据源操作的时候,读取sqlserver的时候,报以上错误。大致意思为:sqlserver类型转换异常,不支持LocalDateTime

第一反应是有两个可能,MP版本,sqlserver版本,MP3.X不应该出现在这问题,于是看了看sql版本,下面应该是我创建项目时自动生成的

<dependency>
    <groupId>com.microsoft.sqlserver</groupId>
    <artifactId>mssql-jdbc</artifactId>
    <scope>runtime</scope>
    <version>6.4.0.jre8</version>
</dependency>


<dependency>
    <groupId>com.microsoft.sqlserver</groupId>
    <artifactId>sqljdbc4</artifactId>
    <version>4.0</version>
    <scope>test</scope>
</dependency>

重点在第一个,查了下,如下图,这时间,感人。。。

 

于是换成了这个。 后面的.jreX就是你的jre版本,用错会提示jre版本不对

 

 

 

        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>mssql-jdbc</artifactId>
            <version>8.4.1.jre8</version>
        </dependency>

启动,运行 OK!

 

 

BTW, 如果用mybatis的,替换之后还不行的话,检查mybatis版本,改成3.5以下的版本就可以了

 

点关注,不迷路,不定时更新。。

 

 

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值