java.sql.SQLException: Zero date value prohibited
今天使用mybatis出现了异常
java.sql.SQLException: Zero date value prohibited
查了下原因
mysql文档上写着
Datetimes with all-zero components (0000-00-00 ...): These values cannot be represented reliably in Java. Connector/J 3.0.x always converted them to NULL when being read from a ResultSet.
Connector/J 3.1 throws an exception by default when these values are encountered, as this is the most correct behavior according to the JDBC and SQL standards.
This behavior can be modified using the zeroDateTimeBehavior configuration property. The permissible values are:
exception(the default), which throws an SQLException with an SQLState ofS1009.
convertToNull, which returnsNULLinstead of the date.
round, which rounds the date to the nearest closest value which is0001-01-01.
zeroDateTimeBehavior默认为exception,会抛出一个SQLException异常
解决的方法:
在jdbcUrl中设置zeroDateTimeBehavior=convertToNull
如:
spring.datasource.url=jdbc:mysql://localhost:3306/mrbird?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull
问题解决
java.sql.SQLException: Zero date value prohibited的更多相关文章
- java.sql.SQLException: Zero date value prohibited 报错分析
今天在使用 iReview 复习词条时,发现 review 页面始终不会跳到下一个词条,应该是前台或者后台出现 BUG 了. 查看浏览器控制台,看到 500 报错,那应该是后台的问题. 登录后台,先查 ...
- java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Date
架构使用jsp+servlet+java+mysql mysql里time字段类型为datetime java实体类中该字段类型为Date 页面中,时间字段类型为空的信息显示不出来,且报错信息如下: ...
- Java:出现错误提示(java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date)
Java:出现错误提示(java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date) 原因分析: ...
- 问题解决:java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
问题描述: 数据表中有记录的time字段(属性为timestamp)其值为:“0000-00-00 00:00:00” 程序使用select 语句从中取数据时出现以下异常: Java.sql.SQLE ...
- java.sql.SQLException: Can not issue data manipulation statements with executeQuery().
1.错误描写叙述 java.sql.SQLException: Can not issue data manipulation statements with executeQuery(). at c ...
- java.sql.SQLException: Can not issue empty query.
1.错误描述 java.sql.SQLException: Can not issue empty query. at com.mysql.jdbc.SQLError.createSQLExcepti ...
- java.sql.SQLException:ORA-01861:文字和格式字符串不匹配
1.错误描述 java.sql.SQLException:ORA-01861:文字和格式字符串不匹配 2.错误原因 字段名为statis_date在数据库中存储的数据类型是Date,而在Java中拼接 ...
- 异常-----java.sql.SQLException:ORA-01861:文字和格式字符串不匹配
1.错误描述 java.sql.SQLException:ORA-01861:文字和格式字符串不匹配 2.错误原因 字段名为statis_date在数据库中存储的数据类型是Date,而在Java中拼接 ...
- Caused by: java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
错误信息如下: Caused by: java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java ...
随机推荐
- 关闭centos大页及swappiness
首先检查THP的启用状态: [root@localhost ~]# cat /sys/kernel/mm/transparent_hugepage/defrag [always] madvise ne ...
- Nginx+keepalived 高可用双机热备(主从模式)
环境:centos7.6 最小化安装 主:10.11.1.32 从:10.11.1.33 VIP:10.11.1.130 修改主节点主机名: hostnamectl set-hostname web_ ...
- C++ vector,list,deque区别(转)
在写C++程序的时候会发现STL是一个不错的东西,减少了代码量,使代码的复用率大大提高,减轻了程序猿的负担.还有一个就是容器,你会发现要是自己写一个链表.队列,或者是数组的时候,既要花时间还要操心 ...
- Python 3的 bytes 数据类型
"""b'\xe6\x88\x91\xe7\x88\xb1Python\xe7\xbc\x96\xe7\xa8\x8b'代表这是一个字节窜,\x代表十六进制表示 e6是十 ...
- js 鼠标事件详细
常用的几个类型 onClick HTML: 2 | 3 | 3.2 | 4 Browser: IE3 | N2 | O3 鼠标点击事件,多用在某个对象控制的范围内的鼠标点击 onDblClick HT ...
- echo如何输出带颜色的文本
本文链接:https://blog.csdn.net/qualcent/article/details/7106483 ######################################## ...
- Js 在页面中输入消息的几种方式
一.方式 alert(“”); confirm(“”) ; prompt(“”); 接收用户信息 console.log(“”); 在网页控制台中输出消息 document. ...
- mysql 获取单个科目的平均分
mysql> select * from test; +----+----------+-------+-----------+ | id | name | score | subject | ...
- CTF SSTI(服务器模板注入)
目录 基础 一些姿势 1.config 2.self 3.[].() 3.url_for, g, request, namespace, lipsum, range, session, dict, g ...
- 非静态内部类中 static/final 成员变量相关知识
原文链接:https://blog.csdn.net/qq_20328181/article/details/81391956