简体   繁体   English

无法将值“ 2012-04-05 10:20:00”从XX列转换为TIMESTAMP

[英]Cannot convert value '2012-04-05 10:20:00' from column XX to TIMESTAMP

A java.sql.SQLException is being thrown when JDBC attempts to convert a valid datetime in MySQL (5.1.51) to a java.sql.timestamp. 当JDBC尝试将MySQL(5.1.51)中的有效日期时间转换为java.sql.timestamp时,将引发java.sql.SQLException。 An example is: 一个例子是:

java.sql.SQLException: Cannot convert value '2012-04-05 10:20:00' from column 40 to TIMESTAMP

This is the first time 这是第一次

Versions:
MySQL: 5.1.51
J/Connector: 5.1.19
Column Definition:  DATETIME
Java Type:   java.sql.Timestamp

stack trace: 堆栈跟踪:

Cannot convert value '2012-04-05 10:20:00' from column 40 to TIMESTAMP.
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927)
    at com.mysql.jdbc.ResultSetRow.getTimestampFast(ResultSetRow.java:1335)
    at com.mysql.jdbc.BufferRow.getTimestampFast(BufferRow.java:576)
    at com.mysql.jdbc.ResultSetImpl.getTimestampInternal(ResultSetImpl.java:6466)
    at com.mysql.jdbc.ResultSetImpl.getTimestamp(ResultSetImpl.java:6066)
    at com.mysql.jdbc.ResultSetImpl.getTimestamp(ResultSetImpl.java:6104)
    at org.apache.tomcat.dbcp.dbcp.DelegatingResultSet.getTimestamp(DelegatingResultSet.java:300)
    at org.apache.tomcat.dbcp.dbcp.DelegatingResultSet.getTimestamp(DelegatingResultSet.java:300)
    at org.apache.tomcat.dbcp.dbcp.DelegatingResultSet.getTimestamp(DelegatingResultSet.java:300)

DAO classes have not been modified recently. DAO类最近未修改。 The only recent change on the server was upgrading MySQL from 5.1.46 to 5.1.51 服务器上的最新更改是将MySQL从5.1.46升级到5.1.51

You could disable Fast Date Parsing by adding useFastDateParsing=false to your JDBC connection URL. 您可以通过在JDBC连接URL中添加useFastDateParsing = false来禁用快速日期解析。 For example the following might solve your problem: 例如,以下可能解决您的问题:

jdbc:mysql://yourHostName:3306/yourDbName?useUnicode=true&useFastDateParsing=false&characterEncoding=UTF-8

I can suggest: 我可以建议:

  1. Try to DEBUG your DAO and look into your Sql Query and try to input manual into the MySQL and you will find more easy the problem. 尝试对您的DAO进行DEBUG并查看您的Sql Query然后尝试将手册输入到MySQL中,您会发现问题更加简单。
  2. Downgrade your MySQL to 5.1.46 is it occur the same problem or not? 将您的MySQL降级到5.1.46是否会发生相同的问题? If yes, then the problem with your table structure. 如果是,则表结构存在问题。 The columns has been changed by someone. 列已被某人更改。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 得到例如“无法将值转换为00:00:00”从第12列到TIMESTAMP的异常“ - Getting the exception like “Cannot convert value '0000-00-00 00:00:00' from column 12 to TIMESTAMP” 如何在Java中将2019-03-26T04:31:40-05:00像字符串那样转换为时间戳? - How to convert 2019-03-26T04:31:40-05:00 like string into timestamp in Java? 如何停止springboot将字符串“2020-02-05 14:20:00”转换为时间戳格式? - how to stop springboot convert string “2020-02-05 14:20:00” to timestamp format? 在Java中将2012年7月5日10:30:00 IST 2012格式转换为2012-07-11 10:30:00.0格式 - Convert thu jul 05 10:30:00 ist 2012 format into 2012-07-11 10:30:00.0 format in java 无法将'0000-00-00 00:00:00'转换为TIMESTAMP - Cannot convert '0000-00-00 00:00:00' to TIMESTAMP 如何将 2017-08-01T16:00:00-04:00 转换为 Java 中的时间戳? - How to convert 2017-08-01T16:00:00-04:00 to timestamp in Java? 如何将“ 2019-04-11T05:00:54.000 + 01:00”转换为dd / MM / yyyy hh:mm格式 - How to convert “2019-04-11T05:00:54.000+01:00” into dd/MM/yyyy hh:mm format 如何使用Java Apache POI将日期格式从2016年5月4日转换为2016年5月4日 - How to convert the date format from 04-May-2016 to 04/05/2016 using Java Apache POI 为什么在Java中,日期1986/05/04从1:00开始但不是从0:00开始(日历与时区的奇怪行为-上海)? - Why does the date 1986/05/04 start from 1:00 but not 0:00 in java ( strange behaviours of calendar with the time zone - Shanghai )? 无法将字符串 '\xAC\xED\x00\x05~r...' 从二进制转换为 utf8mb3 - Cannot convert string '\xAC\xED\x00\x05~r...' from binary to utf8mb3
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM