當我嘗試更新(或替換)我的數據庫中的記錄時,它顯示「數據庫已鎖定」錯誤!SQLITE「數據庫已鎖定」(Java-Eclipse)
例如,這個按鈕應該更新用戶的帳戶詳細信息:
JButton btnUpdate = new JButton("Update");
btnUpdate.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Connection connection3 = SqliteConnection.dbConnector();
PreparedStatement pst1 = null;
try {
String q1 = "replace into Users (FullName,UserName,Email,Password,Question,Answer,UserType) values('"+FullName.getText()+"' ,'"+MainPage.getAuthUser()+"' , '"+Email.getText()+"', '"+Pass.getPassword().toString()+"' , '"+Question.getSelectedItem().toString()+"' , '"+Answer.getText()+"' , '"+UserType.getSelectedItem().toString()+"') ";
//String q1 = "update Users FullName = '"+FullName.getText()+"' where UserName like '"+MainPage.getAuthUser()+"' ";
pst1 = connection3.prepareStatement(q1);
pst1.executeUpdate();
pst1.close();
connection3.close();
} catch (SQLException e6) {
JOptionPane.showMessageDialog(null, e6);
}
}
});
我已經使用了相同的連接插入記錄(創建賬戶),並選擇其中一些(登錄)和那些按鈕的作用精細。
我甚至嘗試關閉連接和語句,在finally塊中,但仍然無法正常工作。