• 解决java.sql.SQLException: Zero date value prohibited


    点击第二页的时候报错java.sql.SQLException: Zero date value prohibited

    前端页面报错如图:

     后端报错如图:

     控制台:

    org.springframework.dao.TransientDataAccessResourceException: Error attempting to get column 'gmt_create' from result set.  Cause: java.sql.SQLException: Zero date value prohibited
    ; Zero date value prohibited; nested exception is java.sql.SQLException: Zero date value prohibited
        at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:110)
        at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
        at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
        at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
        at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
        at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
        at com.sun.proxy.$Proxy107.selectList(Unknown Source)
    。。。。。。。。。。。
    Caused by: com.mysql.cj.exceptions.DataReadException: Zero date value prohibited
        at com.mysql.cj.result.SqlTimestampValueFactory.localCreateFromTimestamp(SqlTimestampValueFactory.java:101)
        at com.mysql.cj.result.SqlTimestampValueFactory.localCreateFromTimestamp(SqlTimestampValueFactory.java:50)
        at com.mysql.cj.result.AbstractDateTimeValueFactory.createFromTimestamp(AbstractDateTimeValueFactory.java:87)
        at com.mysql.cj.protocol.a.MysqlTextValueDecoder.decodeTimestamp(MysqlTextValueDecoder.java:79)
        at com.mysql.cj.protocol.result.AbstractResultsetRow.decodeAndCreateReturnValue(AbstractResultsetRow.java:87)
        at com.mysql.cj.protocol.result.AbstractResultsetRow.getValueFromBytes(AbstractResultsetRow.java:241)
        at com.mysql.cj.protocol.a.result.ByteArrayRow.getValue(ByteArrayRow.java:91)
        ... 94 more

    解决方式:

    在数据库连接的URL后面加上&zeroDateTimeBehavior=convertToNull

    spring.datasource.url=jdbc:mysql://localhost:3306/guli?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull

    参考博文

    【数据库----MySQL】解决java.sql.SQLException: Zero date value prohibited

  • 相关阅读:
    java8
    Python isinstance()
    Python3 File next()
    np.array() 与 np.mat() 比较
    np.nonzero()
    np.dot()
    算法之归并排序的应用 —— 小和问题以及逆序对问题
    递归过程以及递归master公式
    算法之异或运算及其应用
    算法之二分法及其应用
  • 原文地址:https://www.cnblogs.com/ooo888ooo/p/13582407.html
Copyright © 2020-2023  润新知