SSM-物流管理常见问题1Data truncation: Incorrect datetime value: '' for column 'posttime' at row 1

时间:2023-01-28 11:05:52

HTTP Status 500 – Internal Server Error


Type Exception Report

Message Request processing failed; nested exception is org.springframework.dao.DataIntegrityViolationException:

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.dao.DataIntegrityViolationException: 
### Error updating database.  Cause: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: '' for column 'posttime' at row 1
### The error may involve com.dzx.express.mapper.ExpressMapper.insertSelective-Inline
### The error occurred while setting parameters
### SQL: insert into express      ( id,                       fromlocation,                       tolocation,                       phone,                       posttime,                       type )       values ( ?,                       ?,                       ?,                       ?,                       ?,                       ? )
### Cause: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: '' for column 'posttime' at row 1
; SQL []; Data truncation: Incorrect datetime value: '' for column 'posttime' at row 1; nested exception is com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: '' for column 'posttime' at row 1
	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:973)
	org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
	org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
	org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)


翻了很多的原因,最开始怀疑是数据库和代码的utf-8不匹配,排除了,又怀疑是时间类型没有用转换器,排除了。最后看见了一篇博客说mysql的jar包版本可能不对,试了一下,成功了,
我的之前的jar包是mysql-connector-java-5.0.4-bin.jar换成了mysql-connector-java-5.1.7-bin.jar

就可以正常运行了