SpringBoot出现com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Incorrect datetime va

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介: SpringBoot出现com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Incorrect datetime va

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

2.数据库中的时间格式是yyyy-MM-dd,而没有时分秒,所以我将实体类和业务代码中的Date引入的包由java.util.Date都改为了java.sql.Date后

Caused by: com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Incorrect datetime value: '' for column 'ship_time' at row 1
  at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:104)
  at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:955)
  at com.mysql.cj.jdbc.ClientPreparedStatement.execute(ClientPreparedStatement.java:372)
  at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:3409)
  at com.alibaba.druid.wall.WallFilter.preparedStatement_execute(WallFilter.java:619)
  at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:3407)
  at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_execute(FilterEventAdapter.java:440)
  at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:3407)
  at com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl.execute(PreparedStatementProxyImpl.java:167)
  at com.alibaba.druid.pool.DruidPooledPreparedStatement.execute(DruidPooledPreparedStatement.java:498)
  at sun.reflect.GeneratedMethodAccessor134.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:59)
  at com.sun.proxy.$Proxy81.execute(Unknown Source)
  at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:46)
  at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74)
  at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50)
  at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117)
  at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76)
  at sun.reflect.GeneratedMethodAccessor379.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:63)
  at com.sun.proxy.$Proxy172.update(Unknown Source)
  at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:198)
  at sun.reflect.GeneratedMethodAccessor808.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433)
  ... 104 common frames omitted
15:49:21 [http-nio-8080-exec-8] DEBUG o.s.w.s.m.m.a.RequestResponseBodyMethodProcessor - Using 'application/json', given [application/json, text/plain, */*] and supported [application/json, application/*+json, application/json, application/*+json]

 

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
6月前
|
Java 关系型数据库 MySQL
create connection error, url: jdbc:mysql://localhost:3306/ssm, errorCode 1045, state 28000 java.sql.
create connection error, url: jdbc:mysql://localhost:3306/ssm, errorCode 1045, state 28000 java.sql.
|
4月前
|
Java 数据库 Maven
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to
31 0
|
6月前
|
关系型数据库 MySQL Java
【MySQL异常解决】Caused by: com.mysql.cj.exceptions.UnableToConnectException: Public Key Retrieval is not
【MySQL异常解决】Caused by: com.mysql.cj.exceptions.UnableToConnectException: Public Key Retrieval is not
94 0
|
8月前
|
关系型数据库 MySQL Windows
对于测试时,错误信息 Caused by: com.mysql.jdbc.PacketTooBigException: Packet for query is too large
对于测试时,错误信息 Caused by: com.mysql.jdbc.PacketTooBigException: Packet for query is too large
|
9月前
|
关系型数据库 MySQL Java
Mysql 报错:Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure
Mysql 报错:Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure
218 0
|
10月前
|
关系型数据库 MySQL Java
9. 成功解决:Driver class 'org.gjt.mm.mysql.Driver' could not be found
在使用 Kettle(Spoon) 工具创建 MySQL 数据库连接时,提示:Driver class 'org.gjt.mm.mysql.Driver' could not be found, make sure the 'MySQL' driver (jar file) is installed. org.gjt.mm.mysql.Driver
894 0
|
10月前
Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: In aggregated query without GROUP
Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: In aggregated query without GROUP BY, expression #3 of SELECT list contains nonaggregated column
54 0
|
11月前
|
SQL 关系型数据库 MySQL
一次org.springframework.jdbc.BadSqlGrammarException ### Error querying database Cause: com.mysql.jdbc....
一次org.springframework.jdbc.BadSqlGrammarException ### Error querying database Cause: com.mysql.jdbc....
543 0
|
SQL 关系型数据库 MySQL
springboot-plus 导入starter-mysql.sql时出现[Err] 1064 - You have an error in your SQL syntax; check the
springboot-plus 导入starter-mysql.sql时出现[Err] 1064 - You have an error in your SQL syntax; check the
109 0
springboot-plus 导入starter-mysql.sql时出现[Err] 1064 - You have an error in your SQL syntax; check the
|
关系型数据库 MySQL Java
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
212 0