integrity constraint violation: NOT NULL check constraint

佐手、 提交于 2019-12-06 14:45:38

Looks like the table TABLE1 has a NOT NULL constraint on the column CLASSNAME.

It means, you cannot insert a new row into the table without value for the CLASSNAME column.

After inserting the CLASSNAME, you should be updating the same row with the Attributes.

Your current code tries to insert a new row with only Attributes, hence the constraint throws an error.

Your update statement should be as below.

PreparedStatement pstmt = (PreparedStatement) con.prepareStatement("update table1 set Attributes = ? where CLASSNAME = ?");
pstmt.setString(1, textField.getText());
pstmt.setString(2, "Previously Inserted Classname");

Also, check if the table has any other constraints (including a unique primary key )

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!