问题截图
问题
org.springframework.dao.DataIntegrityViolationException: PreparedStatementCallback; SQL [insert into orders values(?,?,?,?,?,?,?,?,?,?,?)]; Data truncation: Incorrect datetime value: '' for column 'create_time' at row 1; nested exception is com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: '' for column 'create_time' at row 1
Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: '' for column 'create_time' at row 1
日期源代码
order.setCreateTime(new Date());
数据库结构
解决方法
Date nowdate=new Date();
SimpleDateFormat simpleDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
order.setCreateTime(Timestamp.valueOf(simpleDate.format(nowdate)));
参考博客