出现 Data truncated for column 'date' at row 1 的错误解决方案

时间:2021-12-08 17:09:54
严重: Servlet.service() for servlet [spring-mvc] in context with path [/DBDX] threw exception [Request processing failed; nested exception is com.dbdx.util.DaoException: 数据库操作失败!; nested exception is org.springframework.dao.DataIntegrityViolationException: PreparedStatementCallback; SQL [insert into z_praise(kt_id,t_id,date,deleted) values(?,?,?,?)]; Data truncated for column 'date' at row 1; nested exception is java.sql.SQLException: Data truncated for column 'date' at row 1] with root cause

java.sql.SQLException: Data truncated for column 'date' at row 1


在看到SQLException后开始以为是sql语句写错的原因,但反复检查后还是不行,后发现是数据库表的类型是int可能数据长度不都,改为varchar解决。