我在通过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
发布评论