nested exception is com.microsoft.sqlserver.jdbc.SQLServerException

今天在写一个数据库语句的时候,出现了一个错误,话不多说,上图

nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: 仅当使用了列列表并且 IDENTITY_INSERT ON 时,才能为表'Categories'中的标识列指定显式值。

出错原因可能就是:数据库表的 id 设置为 自增长,那么,写sql语句的时候,就不能写成

String sql = insert into  category values(null,?,?,?,?,?,?),

应该写成

String sql = insert into category values(?,?,?,?,?,?)

猜你喜欢

转载自blog.csdn.net/manqishizhizhu/article/details/106522052