Cause: com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Incorrect date value

Cause: com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Incorrect date value: ‘1541123218569‘ for column ‘create_time‘ at row 1

遇到这种问题的原因有两种

1、可能是表中设置的字符集与你想要插入的字符集不相同。

解决方法:

(1)修改数据库默认编码ALTER DATABASE `test` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;

(2)修改表的编码:ALTER TABLE `表名` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;

(3)修改表字段的编码ALTER TABLE `表名` CHANGE `字段名` `字段名` VARCHAR( 45 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL;

(4)查看你表的编码和表中字段的编码格式:在表上点击右键——表讯息——DDL 可以看到表和字段的编码格式,要是跟你配置文件中的不一致的话修改就OK了,修改方法:在表上点击右键——设计表——选项——字符集 ,然后点击你表中的每个字符串字段,查看下面的字符集编码是否一致

2、你想要插入表的数据的长度可能超过你设置的长度。

解决方法:

varchar改为text后,问题解决,解决方法是:在数据库里将这个字段类型设为text或者更大的longtext类型

原文地址:https://www.cnblogs.com/qingmuchuanqi48/p/11747040.html

时间: 2024-10-21 09:30:25

Cause: com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Incorrect date value的相关文章

mysql 插入中文报错: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value...

总结写在前面, 总结: 当Java通过jdbc链接mysql插入中文时,要保证程序可以正常执行,而且插入的中文不会乱码, mysql服务器端,对数据表(不是数据库)的编码设置,要保证是支持中文的,例如gbk, gb2312, utf-8 jdbc的连接配置,要开启useUnicode=true,并且要设置一个支持中文的编码,不需要跟mysql表的编码保持一致,只需要支持中文就行.例如characterEncoding=utf8 本身的Java文件的编码需要支持中文 ===============

com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. at com.mysql.cj.jdbc.exceptions.SQLErro

ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] - Data truncation: Incorrect datetime value: '' for column 'pubdate' at row 1

之前的Connector/J版本是:mysql-connector-java-5.0.4-bin.jar 后来换成mysql-connector-java-5.1.45-bin.jar,问题解决 2018-02-16 01:07:10,086 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] - SQL Error: 0, SQLState: 220012018-02-16 01:07:10,086 ERROR [org.hibern

解决:com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure(真实有效)

数据库连接失败 一.例如我在SpringBoot项目中使用了阿里的数据库连接池Driud. 有次在启动的时候,会报这样的错: Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure The last packet successfully received from the server was 319 milliseconds ago. The last packet s

Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'content' a

1.错误描述 org.hibernate.exception.DataException: could not execute statement at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:69) at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert

Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value: 'L

1.错误描述 [ERROR:]2015-06-08 09:49:42,523 [异常拦截] org.hibernate.exception.DataException: error executing work at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:69) at org.hibernate.exception.internal.Stand

com.mysql.jdbc.MysqlDataTruncation: Data truncation异常

Exception in thread "main" com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'note' at row 1 at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2868) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573) at co

Spring Boot连接MySQL长时间不连接后报错`com.mysql.cj.core.exceptions.ConnectionIsClosedException: No operations allowed after connection closed.`的解决办法

报错:com.mysql.cj.core.exceptions.ConnectionIsClosedException: No operations allowed after connection closed. 添加 &autoReconnect=true 无济于事,此选项好像仅对 MySQL 5之前的版本有效. 原因 Mysql服务器默认的"wait_timeout"是8小时,也就是说一个connection空闲超过8个小时,Mysql将自动断开该connection.这

com.mysql.jdbc.Driver ==》 com.mysql.cj.jdbc.Driver

错误信息: SqlSession [[email protected]] was not registered for synchronization because synchronization is not active Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatical