java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
### Error querying database.Cause: java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
### The error may exist in file [/Users/albert/Workspace/IDEA/SmartCompus/target/SmartCompus/WEB-INF/classes/com/komlin/modular/smart/mapper/mapping/RoomWorkTypeMapper.xml]
### The error may involve com.komlin.modular.smart.mapper.RoomWorkTypeMapper.listByCondition
### The error occurred while handling results
### SQL: select room_work_type.*, mr_name,mr_placefrom room_work_typeleft join meet_room on rwt_room_id = mr_id limit 0,10
### Cause: java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
;
SQL [];
Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp;
nested exception is java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:108) ~[spring-jdbc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73) ~[spring-jdbc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
以上是我的异常;
原因 【java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp】数据库没有存时间,在jdbc中进行转化时,无法转化。就会抛出改异常
解决
- 整理数据库数据
- 在数据库连接时添加zeroDateTimeBehavior=convertToNull 自动转化为null
jdbc.url=jdbc:mysql://127.0.0.1:3306/oa?zeroDateTimeBehavior=convertToNull
推荐阅读
- Java|Java基础——数组
- 人工智能|干货!人体姿态估计与运动预测
- java简介|Java是什么(Java能用来干什么?)
- Java|规范的打印日志
- Linux|109 个实用 shell 脚本
- 程序员|【高级Java架构师系统学习】毕业一年萌新的Java大厂面经,最新整理
- Spring注解驱动第十讲--@Autowired使用
- SqlServer|sql server的UPDLOCK、HOLDLOCK试验
- jvm|【JVM】JVM08(java内存模型解析[JMM])
- 技术|为参加2021年蓝桥杯Java软件开发大学B组细心整理常见基础知识、搜索和常用算法解析例题(持续更新...)