ITPub博客

首页 > IT职业 > IT生活 > mysql datetime查询异常问题解决

mysql datetime查询异常问题解决

IT生活 作者:smith12us 时间:2021-09-09 09:39:16 0 删除 编辑

mysql datetime查询异常

  1. 异常:Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp (2011-05-25 11:38:40)

  2. 描述:非空无默认值的Datetime类型字段,查询时程序报以下错误: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp

  3. 解决方法:数据库连接串添加zeroDateTimeBehavior参数或者noDatetimeStringSync参数jdbc:mysql://host:port/xxx?...

zeroDateTimeBehavior:取值exception、converToNull、round

  1. exception---抛出异常:结果java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp。

  2. converToNull:返回null值

  3. round:返回0001-01-01 00:00:00.0

noDatetimeStringSync:设置为true,返回0000-00-00 00:00:00

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/3181/viewspace-2805633/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-08-30

  • 博文量
    80
  • 访问量
    515