Caused by: java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Tim
2013-10-29 16:09
656 查看
1.错误
2.解决
zeroDateTimeBehavior=convertToNull
Cannot convert value '0000-00-00 00:00:00' from column 1 to TIMESTAMP 在Mysql数据库中使用DATETIME类型来存储时间,使用JDBC中读取这个字段的时候,应该使用 ResultSet.getTimestamp(),这样会得到一个java.sql.Timestamp类型的数据。在这里既不能使用 ResultSet.getDate(),也不能使用ResultSet.getTime(),因为前者不包括time数据,后者不包括date数据。 但是在使用ResultSet.getTimestamp()时也不是完全安全的,例如,当数据库中的TIMESTAMP类型的字段值为 '0000-00-00 00:00:00'时,使用此方法进行读取,会抛出异常:Cannot convert value '0000-00-00 00:00:00' from column 1 to TIMESTAMP,这是因为JDBC不能将'0000-00-00 00:00:00'转化为一个为一个java.sql.Timestamp,在Java中,想创建一个java.util.Date,使其值为 '0000-00-00'也是不可能的,最古老的日期应该是'0001-01-01 00:00:00'。 |
相关文章推荐
- Caused by: java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Tim
- java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Tim
- Cause: java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timest
- ibatis java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timest
- ssm、ssh 出现 java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.T
- mysql 数据库字段为datetime类型时默认值为:0000-00-00 00:00:00 查询时异常 java.sql.SQLException:Value '0000-00-00' can not be represented as java.sq
- Mysql 报错java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timest
- 异常:java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
- 关于SQLException:Value'0000-00-00 00:00:00'can not be represented as java.sql.Timestamp的问题
- mysql时间格式默认为null抛出java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java
- java.sql.SQLException:Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp错误解决
- Caused by: java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Date
- 异常java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
- java.sql.SQLException: Value ‘0000-00-00 00:00:00’ can not be represented as java.sql.Timestamp
- 问题解决:java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
- 错误:Value \'0000-00-00 00:00:00\' can not be represented as java.sql.Timestamp;的解决
- mysql解决Value ‘0000-00-00 00:00:00’ can not be represented as java.sql.Timestamp
- java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
- [DEBUG] “java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Timestamp”
- MySQL 关于 Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestam