尝试打开多个jframe时数据库被锁定 [英] Database locked while trying to open multiple jframes
问题描述
我的问题是,当我尝试使用该jframe时(例如,将数据插入SQLite Manager的数据库中),打开一个包含与主jframe信息不同的信息的jframe时.但这给了我数据库锁定错误.我可以从主jframe插入数据,而我正在使用jcombobox打开新的jframe.我想我知道来源,但我不知道如何解决这个问题.我认为我需要关闭我打开其他框架的主jframe.因此,sqlite数据库可以存储这些帧数据.在这里,我将向您介绍如何使用jcombobox打开jframe,以及如何尝试将数据插入数据库.请帮助我或,发表评论您对这个问题的想法.我对来源的想法有误还是对的.我需要你们的帮助.感谢您的阅读.
My problem is , while opening a jframe which is including different informations than my main jframe , when i tried to work on this jframe, for example inserting data to SQLite manager's database . But it's giving me Database locked error.I can insert data from my main jframe which i'm opening new jframes with jcombobox. I hink i know source but i dont know how to fix this. I think i need to close my main jframe which i open other frames. So sqlite database can storage this frames datas. Here i'll give to you how can i open jframes with jcombobox and how i'm trying to insert a data to database. Please help me or , leave a comment what're you thinking about this problem. Am i wrong with source idea or true. I need your helps guys. Thanks for reading.
1:这编码了我如何使用组合框打开jframe.
1: This codes how i'm opening jframes with combobox.
public void comboselect(){
int d =ComboBox_name.getSelectedIndex();
if (d==0){
CezalıUye s=new CezalıUye();
s.setVisible(true);
dispose();
}
if(d==1){
DeaktifUye z=new DeaktifUye();
z.setVisible(true);
dispose();
}
if(d==2){
TatbikatForm l=new TatbikatForm();
l.setVisible(true);
dispose();
}
}
2:这编码了我试图插入从jcombobox打开的数据的方式.
2:This codes how i'm trying to insert data which i opened from jcombobox.
private void cmd_saveActionPerformed(java.awt.event.ActionEvent evt) {
try{
String sql = "Insert into cezalitablosu (KimTarafından,Kime,Neden,Kaçıncı,Tarih) values (?,?,?,?,?)";
pst=conn.prepareStatement(sql);
pst.setString(1, jTextField1.getText());
pst.setString(2, jTextField2.getText());
pst.setString(3, jTextField3.getText());
pst.setString(4, jTextField4.getText());
pst.setString(5, jTextField5.getText());
pst.execute();
JOptionPane.showMessageDialog(null, "Kaydedildi!");
}
catch(Exception e)
{
e.printStackTrace();
JOptionPane.showMessageDialog(null, e);
}
Update_table();
}
推荐答案
execute()不能用于插入,更新和删除.
execute() can not be use for insert,update and delete.
对于插入,更新和删除,始终使用
For insert,update and delete always use
executeUpdate();
这篇关于尝试打开多个jframe时数据库被锁定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!