您能否举一个简单的示例,说明如何使用SQLContainer从数据库中删除记录。
我尝试使用SQLContainer.Removeid(itemID)
,但仍然无法正常工作。希望可以有人帮帮我。
这是我尝试过的:
try {
SQLContainer DeleteContainer = new SQLContainer(new TableQuery("tbl_grade", connectionPool));
Object ItemID = "10";
DeleteContainer.removeItem(ItemID);
DeleteContainer.commit();
} catch (SQLException ex) {
ex.printStackTrace();
}
最佳答案
您需要提供项目的Id
作为RowId
类的实例。
尝试这个:
(假设项目的Id
是Integer
类型)
try {
SQLContainer deleteContainer = new SQLContainer(new TableQuery("tbl_grade", connectionPool));
RowId itemID = new RowId(new Integer[] { 10 });
deleteContainer.removeItem(itemID);
deleteContainer.commit();
} catch (SQLException ex) {
ex.printStackTrace();
}
关于java - Vaadin从数据库中删除一条记录,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22369575/