Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
234 views
in Technique[技术] by (71.8m points)

java - Database locked while trying to open multiple jframes

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();


    }       
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

execute() can not be use for insert,update and delete.

For insert,update and delete always use

executeUpdate();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...