MySQL:数据截断:不正确的日期时间值:'2006

编程入门 行业动态 更新时间:2024-10-25 12:19:29
本文介绍了MySQL:数据截断:不正确的日期时间值:'2006-10-01 02:22:44'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在通过JDBC使用MySQL更新行时遇到以下异常:

I'm getting the following exception updating a row using MySQL via JDBC:

com.mysql.jdbc.MysqlDataTruncation:数据截断:不正确的日期时间值:'2006-10-01 02:22:44'

com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: '2006-10-01 02:22:44'

该列定义为:

'created_on_service时间戳为NULL默认为NULL'

'created_on_service timestamp NULL DEFAULT NULL'

该列上没有索引或外键.

There are no indexes or foreign keys on that column.

显然,数据类型不是问题.我在该表中具有该日期时间之前和之后的值.我还具有在2:22 AM之前和之后的时间值.

Obviously it's not a problem with data type. I have values in that table from both before and after that datetime. I also have values with times both before and after 2:22 AM.

推荐答案

已解决.

事实证明,2006年10月1日在南澳大利亚州开始了夏令时.时钟在凌晨2:00向前调一小时,因此该日期没有凌晨2:22:从凌晨2:00一直凌晨3:01.

Turns out that the 1st of October 2006 in South Australia was the start of daylight savings. Clocks get set forward one hour at 2.00am, so there was no 2:22am on that date: it went straight from 2:00am to 3:01am.

我将数据库时区更改为UTC,这将解决此问题.

I'll change the db timezone to UTC, which should solve this issue.

更多推荐

MySQL:数据截断:不正确的日期时间值:'2006

本文发布于:2023-10-24 08:52:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1523492.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不正确   日期   时间   数据   MySQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!