IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    [原]The connection property \'zeroDateTimeBehavior\' only accepts values of the form: \'exception\', \'round\'

    testcs_dn发表于 2017-03-22 17:55:09
    love 0

    The connection property 'zeroDateTimeBehavior' only accepts values of the form: 'exception', 'round' or 'convertToNull'. The value 'convertToNull ' is not in this set.


    这个问题是解决以下问题出现的:

    java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp

    问题原因是因为JDBC 

    url=jdbc:mysql://xxx.aliyuncs.com:3306/xxxxx?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull

    字符串后面因为是从网页上复制的,后面多了一个空格。

    错误信息中已经提示了 zeroDateTimeBehavior 属性可以接受 'exception', 'round' or 'convertToNull'中的一个。


    默认是 exception,抛出异常

    round 是返回:0001-01-01 00:00:00.0

    convertToNull  就是转换为 null

    ======================文档信息========================

    版权声明:非商用自由转载-保持署名-注明出处

    署名(BY) :testcs_dn(微wx笑)

    文章出处:[无知人生,记录点滴](http://blog.csdn.NET/testcs_dn)

    ==============欢迎关注我的个人微信订阅号(微wx笑)============




沪ICP备19023445号-2号
友情链接