我正在尝试使用 SWT/Jface 数据通过 ibatis 实现删除 SWT 表行。
每当我尝试从客户端(SWT)进行插入或删除操作时,我都会遇到异常。
org.apache.ibatis.exceptions.PersistenceException:
### Error committing transaction. Cause: java.sql.SQLException: database is locked
当我尝试直接通过 ibatis 访问 DB (SQLite) 时,不会发生这种情况。
下面是我正在使用 SWT 按钮执行删除操作并尝试删除 SWT 表行的代码部分。
SWT 代码....
btnDeleteWorkspaceRow.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
IStructuredSelection selection = (IStructuredSelection) m_workplaceViewer.getSelection();
WorkplaceDetail workplaceDetail = (WorkplaceDetail) selection.getFirstElement();
boolean confirm = MessageDialog.openConfirm(shell, "Confirm Delete", "Are you sure you want to delete row"+ + workplaceDetail.getCode() + "'?");
if (confirm) {
**int code =186;** (Hardcoded row value- actual DB row number)
WorkplaceDaoImpl workplaceDaoImpl = new WorkplaceDaoImpl();
try {
**WorkplaceDaoImpl.deleteWorkplaceDetail(code);**
} catch (SQLException e1) {
e1.printStackTrace();
}
m_bindingContext.updateModels();
}
}
});
This is Ibatis DAO implementation code which i am invoking in SWT
**WorkplacseDaoImpl.java**
public void deleteWorkplaceDetail(int code)
throws SQLException {
SqlSession session = sqlSessionFactory.openSession();
session.delete("WorkplaceDetail.deleteWorkplaceById", code);
session.commit();
session.close();
}
**Ibatis Configuration**
<delete id="deleteWorkplaceById">
delete from Workplace where workplaceCode=#{code}
</delete>
Please help me to resolve this issue. I am using SQLite DB