Cannot convert '0000-00-00 00:00:00' to TIMESTAMP

后端 未结 2 1736
囚心锁ツ
囚心锁ツ 2020-12-30 21:11

the field definition

 /** Date. */
  @Column(columnDefinition = \"datetime\")
  private Date date;

setter

public void setDa         


        
2条回答
  •  余生分开走
    2020-12-30 21:39

    I'm going to take a wild guess here that you're using MySQL :-) It uses "zero dates" as special placeholder - unfortunatelly, JDBC can not handle them by default.

    The solution is to specify "zeroDateTimeBehavior=convertToNull" as parameter to your MySQL connection (either in datasource URL or as an additional property), e.g.:

    jdbc:mysql://localhost/myDatabase?zeroDateTimeBehavior=convertToNull
    

    This will cause all such values to be retrieved as NULLs.

提交回复
热议问题