【发布时间】:2020-09-08 02:17:46
【问题描述】:
JDBC sql server:设置 IDENTITY_INSERT ON:无效。
PreparedStatement stmt = connection.prepareStatement("SET IDENTITY_INSERT Table_FOO ON");
stmt.execute();
stmt.close();
PreparedStatement stmt2 = connection.prepareStatement("insert into Table_FOO (id, name) values (100, 'abc')");
stmt2.execute();
stmt2.close();
错误:仍然抱怨 DENTITY_INSERT 处于关闭状态。
com.microsoft.sqlserver.jdbc.SQLServerException:当 IDENTITY_INSERT 设置为 OFF 时,无法在表“Table_FOO”中插入标识列的显式值。
【问题讨论】:
标签: sql-server jdbc identity-insert