Error updating database. Cause: java.sql.SQLException: Field 'id' doesn't have a default value
异常:
具体的异常信息:
org.springframework.jdbc.UncategorizedSQLException:
### Error updating database. Cause: java.sql.SQLException: Field 'id' doesn't have a default value
### The error may involve com.showsoft.mapper.UserMapper.saveOne-Inline
### The error occurred while setting parameters
### SQL: INSERT into t_user( account, password, createTime, updateTime )VALUES ( ?, ?, now(), now() )
### Cause: java.sql.SQLException: Field 'id' doesn't have a default value
; uncategorized SQLException for SQL []; SQL state [HY000]; error code [1364]; Field 'id' doesn't have a default value; nested exception is java.sql.SQLException: Field 'id' doesn't have a default value
错误原因分析:
“Field 'id' doesn't have a default value” id是user表的主键id,错误提示此id没有默认值,去数据库设计表看了下表结构,我在新建表字段的时候,没有将id设置为自增长类型(主键自增)。
解决办法:
将主键id设置为“自动递增”