当我尝试更新(或替换)我的数据库中的记录时,它显示“数据库已锁定”错误!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块中,但仍然无法正常工作。