zoukankan      html  css  js  c++  java
  • 解决提示Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp;的方法

    Mysql在进行查询时报了一个

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

    这样的错误,这是因为在默认插入一个类型为timestamp的时间时它会将'0000-00-00 00:00:00‘插入,但是在数据库定义时又因为设计是非空的timestamp类型的时间,所以查询时就会出错,并且mysql的时间范围是:'1000-01-01 00:00:00' 到 '9999-12-31 23:59:59'这个时间段,所以会报错,目前的解决办法是在jdbc连接文件中添加一句:

    &zeroDateTimeBehavior=convertToNull

    url=jdbc:mysql://localhost:3306/seckill?useUnicode=true&characterEncoding=utf8&&zeroDateTimeBehavior=convertToNull

    目前这个方法还是有用的,但是到了后边不知道会不会会有新的问题出现。

  • 相关阅读:
    csp-s模拟 77/78 (达哥专场)
    csp-s 模拟76
    csp-s模拟75 导弹袭击
    反思集
    模拟69/70 考试反思
    抱大腿
    csp-s模拟61 甜圈
    实时记录
    好题思路集汇
    半集训反思 8.28 「路,还是要自己走的」
  • 原文地址:https://www.cnblogs.com/future-liu1121/p/7768926.html
Copyright © 2011-2022 走看看