mybatis-mysql:数据库字段类型为 TIMESTAMP 类型;实体类对应为 String 类型;在添加数据此字段为空或者查询此字段为空的数据时,程序报错:Cause: java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timesta
解决方案:在配置数据库url的文件(我的是applicationContext.xml)中,在url末尾添加 zeroDateTimeBehavior=round ,查询结果返回null
修改前:
<property name="url">
<value>jdbc:mysql://localhost:3306/web_shop?useUnicode=true&characterEncoding=utf-8</value>
</property>
修改后:
<property name="url">
<value>jdbc:mysql://localhost:3306/web_shop?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=round</value>
</property>