java java.sql.SQLException: Cannot convert value '0000-00-00 00:00:00' from column 5 to TIMESTAMP.
2017-04-14 10:07
761 查看
在Java中,从MySQL数据库拿timestamp类型的数据,如果数据为’0000-00-00 00:00:00‘,那
用ResultSet.getTimestamp()拿数据的时候就会报该错误信息,此时只需要在数据库的url的末尾加上?relaxAutoCommit=true&zeroDateTimeBehavior=convertToNull就可以,如:
String url = “jdbc:mysql://192.168.11.11:3306/db?relaxAutoCommit=true&zeroDateTimeBehavior=convertToNull”;
ok,问题解决~
用ResultSet.getTimestamp()拿数据的时候就会报该错误信息,此时只需要在数据库的url的末尾加上?relaxAutoCommit=true&zeroDateTimeBehavior=convertToNull就可以,如:
String url = “jdbc:mysql://192.168.11.11:3306/db?relaxAutoCommit=true&zeroDateTimeBehavior=convertToNull”;
ok,问题解决~
相关文章推荐
- java.sql.SQLException: Cannot convert value '0000-00-00 00:00:00' from column aa to TIMESTAMP
- java java.sql.SQLException: Cannot convert value '0000-00-00 00:00:00' from column 5 to TIMESTAMP.
- java的JDBC连接mysql数据库时对于Datetime类型出现Cannot convert value '0000-00-00 00:00:00' from column 9 to TIMESTAMP.
- Mysql-提示java.sql.SQLException: Cannot convert value '0000-00-00 00:00:00' from column 7 to TIMESTAMP.
- Cannot convert value '0000-00-00 00:00:00' from column 1 to TIMESTAMP,url问题:对实体"*"的引用必须以 ';' 分隔符结尾
- 开发 - Cannot convert value '0000-00-00 00:00:00' from column 38 to TIMESTAMP.
- Cannot convert value '0000-00-00 00:00:00' from column 1 to TIMESTAMP
- MYSQL:Cannot convert value '0000-00-00 00:00:00' from column 10 to TIMESTAMP的解决办法
- Cannot convert value '0000-00-00 00:00:00' from column 1 to TIMESTAMP分析及解决办法
- java.sql.SQLException: Cannot convert value '2017-07' from column 6 to TIMESTAMP.
- java.sql.SQLException: Cannot convert value '0000-00-00 00:00:00' from column 7 to TIMESTAMP
- Cannot convert value '0000-00-00 00:00:00' from column 1 to TIMESTAMP .
- java的JDBC连接mysql数据库时对于Datetime类型出现Cannot convert value '0000-00-00 00:00:00' from column 9 to TIMESTAMP
- JDBC报错java.sql.SQLException: Cannot convert value '0000-00-00 00:00:00' from column 14 to T
- 关于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
- Cannot convert value '0000-00-00 00:00:00' from column 1 to TIMESTAMP
- Hibernate Cannot convert value '0000-00-00 00:00:00' from column 5 to TIMESTAMP
- Cannot convert value '0000-00-00 00:00:00' from column 1 to TIMESTAMP
- Cannot convert value '0000-00-00 00:00:00' from column 22 to TIMESTAMP