mysql数据库中的字段类型datetime,通常是正常的时间类型比如2021-04-11 18:10:06或者null,

但有时候在导入数据的时候这个字段的值会变成0000-00-00 00:00:00,这种情况下查询就出现错误。

这是因为0000-00-00 00:00:00在数据库是允许出现的特殊值,但是会被jvm认为不合法的。

解决办法

1、避免数据库出现这个时间

2、在数据库的链接url后加上zeroDateTimeBehavior,

例如:url=jdbc:mysql:***?zeroDateTimeBehavior=convertToNull

zeroDateTimeBehavior有3个值分别表示

convertToNull:出现时间0000-00-00 00:00:00时转为null

round:出现时间0000-00-00 00:00:00时转为0001-01-01 00-00-00

exception:默认值,抛出异常

关于Value ‘0000-00-00 00:00:00‘ can not be represented as java.sql.Timestamp错误相关推荐

  1. mysql解决Value ‘0000-00-00 00:00:00’ can not be represented as java.sql.Timestamp

    同步发布:http://www.yuanrengu.com/index.php/mysqlsolvetimestamp.html 在使用mysql时,如果数据库中的字段类型是timestamp,默认为 ...

  2. 错误: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;刚开始 ...

  3. 关于Value ‘0000-00-00 00:00:00‘ can not be represented as java.sql.Timestamp异常问题的解读

    前提 对于必传的字段, 新需求改为非必填的时候,在测试环境出现了 Value '0000-00-00 00:00:00' can not be represented as java.sql.Time ...

  4. java.sql.SQLException: Value ”0000-00-00 00:00:00“ can not be represented as java.sql.Timestamp

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

  5. 已解决:java.sql.SQLException: Value ‘0000-00-00 00:00:00‘ can not be represented as java.sql.Timestamp

    一.问题 一大早到公司 Mysql 中的一个 datetime 字段时碰到了一个 Cause: java.sql.SQLException: Value '0000-00-00 00:00:00' c ...

  6. MySQL 错误【四】Value ‘0000-00-00 00:00:00’ can not be represented as java.sql.Timestamp

    1. 错误描述 在使用mysql时,如果数据库中的字段类型是timestamp,默认为0000-00-00,会发生异常:Value '0000-00-00 00:00:00' can not be r ...

  7. Cause: java.sql.SQLExceptioValue ‘0000-00-00 00:00:00‘ can not be represented as java.sql.Timestamp

    今天使用mybatis创建demo测试的时候发现了一个有意思的bug org.apache.ibatis.exceptions.PersistenceException: ### Error quer ...

  8. Value ‘0000-00-00 00:00:00‘ can not be represented as java.sql.Timestamp

    程序使用select 语句查询数据时,出现以下异常: java.sql.SQLException:Value '0000-00-00' can not be represented as java.s ...

  9. MySQL错误:Value ‘0000-00-00 00:00:00‘ can not be represented as java.sql.Timestamp

    java项目,使用MySQL,字段类型为timestamp,字段值默认为0000-00-00 00:00:00. 在解析数据时会抛出一个异常: java.sql.SQLException: Value ...

最新文章

  1. webservice gsoap 小记
  2. 想拿下互联网大厂OFFER,都需要准备什么?
  3. 【java】之常用四大线程池用法以及ThreadPoolExecutor详解
  4. iOS网络请求之multipart/form-data提交数据
  5. 一套不错的php,一套不错的PHP笔试题-附答案.pdf
  6. linux运行多线程语句,linux多线程中使用system函数后时而程序崩溃,求助!!!...
  7. TextView scrollbars setting
  8. Python3 编写处理Excel表格数据筛选脚本用到的一些方法
  9. 机器学习数学基础——群论
  10. 云服务器上安装 R语言 以及 RStudio Server 详细图文操作(全)
  11. 求助:用Python获取百度云服务access_token总是失败
  12. 不是吧阿sir,你不会还不知道Github可以当做Maven仓库吧
  13. 使用selenium爬取网易云热门评论(超详细)
  14. android 判断键盘是否弹起
  15. 电脑d盘和e盘不见了怎么恢复?
  16. 论文查重:降低重复率技巧
  17. 猫眼电影院爬虫(可用)
  18. w ndows10启动,手把手为你win10系统设置开机自动启动adsafe软件的详细教程
  19. 如何监测耳机/麦克风设备插拔操作
  20. 串讲数字电路与系统设计提前预告

热门文章

  1. 45页精华《2022中国建筑行业数字化转型研究报告》出炉(附下载)
  2. 华为OD机试题:身高体重排序
  3. html 在框架里弹出页面,iframe弹出新窗口 iframe页面打开新窗口问题
  4. An internal error occurred during: Validating SYYH. Java heap space
  5. 21天学会Linux----Day1:Linux环境搭建
  6. 让360浏览器强制优先使用极速模式
  7. 《安富莱嵌入式周报》第287期:下一代Windows12界面,支持各种工业以太网协议参考,百款在线电子开发工具,seL4安全微内核,旋转拨号手机,PSP掌机逆向
  8. TCGA数据库的利用(二)—— 数据处理
  9. Cisco ❀ ICMP-互联网控制报文协议
  10. Redis详解之特殊数据类型GEO及底层数据结构