问题
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: 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: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();
}
回答1:
execute() can not be use for insert,update and delete.
For insert,update and delete always use
executeUpdate();
来源:https://stackoverflow.com/questions/18499736/database-locked-while-trying-to-open-multiple-jframes