java.sql.SQLException: Value'0000-00-00'异常解决办法
2017-12-01 11:35
405 查看
在使用MySql 时, 数据库中的字段类型是timestamp的,默认为0000-00-00, 会发生异常:java.sql.SQLException: Value '0000-00-00 ' can not be represented as java.sql.Timestamp
解决办法:
给jdbc url加上 zeroDateTimeBehavior参数:
datasource.url=jdbc:mysql://localhost:3306/testdb?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true
zeroDateTimeBehavior=round是为了指定MySql中的DateTime字段默认值查询时的处理方式;默认是抛出异常,
对于值为0000-00-00 00:00:00(默认值)的纪录,如下两种配置,会返回不同的结果:
zeroDateTimeBehavior=round 0001-01-01 00:00:00.0
zeroDateTimeBehavior=convertToNull null
解决办法:
给jdbc url加上 zeroDateTimeBehavior参数:
datasource.url=jdbc:mysql://localhost:3306/testdb?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true
zeroDateTimeBehavior=round是为了指定MySql中的DateTime字段默认值查询时的处理方式;默认是抛出异常,
对于值为0000-00-00 00:00:00(默认值)的纪录,如下两种配置,会返回不同的结果:
zeroDateTimeBehavior=round 0001-01-01 00:00:00.0
zeroDateTimeBehavior=convertToNull null
相关文章推荐
- [mysql]java.sql.SQLException: Value'0000-00-00'异常解决办法
- java.sql.SQLException: Value'0000-00-00'异常解决办法[转]
- java.sql.SQLException: Value'0000-00-00'异常解决办法
- java.sql.SQLException: Value'0000-00-00'异常解决办法
- java.sql.SQLException: Value'0000-00-00'异常解决办法及mysql的url设置
- java.sql.SQLException: Value'0000-00-00'异常解决
- 问题解决:java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
- 问题解决:java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
- 问题解决:java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
- 问题解决:java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
- 问题解决: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
- 异常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
- 异常: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' can not be represented as java.sql.Date解决办法
- Value '0000-00-00' can not be represented as java.sql.Date解决办法
- 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错误解决