MyBatis错误提示:Error updating database. Cause: java.sql.SQLException: Field 'id' doesn't have a defaul

MyBatis错误输出:

org.apache.ibatis.exceptions.PersistenceException: 
### Error updating database.  Cause: java.sql.SQLException: Field 'id' doesn't have a default value
### The error may exist in com/smbms/dao/provider/ProviderMapper.xml
### The error may involve com.smbms.dao.provider.ProviderMapper.addProvider-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO `smbms_provider`( `proCode`,`proName`,`proDesc`,`proContact`         ,`proPhone`,`proAddress`,`proFax`,`createdBy`,`creationDate`)         VALUES(?,?,?,?,?         ,?,?,?,?);
### Cause: java.sql.SQLException: Field 'id' doesn't have a default value

首先我们对输出的错误信息进行分析,可以很清晰的发现,其中有一句提示为Field 'id' doesn't have a default value,它的意思是字段“id”没有默认值,这个问题的解决方案是,在SQL语句中加上该字段,或者如果他可以是一个自动增长列就把它设置为自动增长列。我这里直接将它设置为自动增长列:
MyBatis错误提示:Error updating database. Cause: java.sql.SQLException: Field 'id' doesn't have a defaul_第1张图片这时我们运行程序,可以发现程序运行成功了:
MyBatis错误提示:Error updating database. Cause: java.sql.SQLException: Field 'id' doesn't have a defaul_第2张图片问题成功的被我们解决啦!

你可能感兴趣的:(MyBatis错误提示:Error updating database. Cause: java.sql.SQLException: Field 'id' doesn't have a defaul)