今天在写一个数据库语句的时候,出现了一个错误,话不多说,上图
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(?,?,?,?,?,?)
更多推荐
nested exception is com.microsoft.sqlserver.jdbc.SQLServerException
发布评论