vendredi 16 octobre 2015

Sqlite database is locked when merge two database

I try to attach one database to another database and not duplicate value . I used these query in command line and it's successful . Before writing this code , I have an other code but it crash my server continuity . So I change this code . But I don't understand why it's locked my database

 public void mergeFile() {
    try (Connection conn = new sqlite_cnn().getCnn()) {
        conn.prepareStatement("attach database 'D:" + File.separator + "database" + File.separator + "mydatabase' as tomerge").execute();
        conn.prepareStatement("insert  into message(phone,message,crDate,tinh,haiso,baso) select phone,message,crDate,tinh,haiso,baso from tomerge.message where tomerge.message.message not in (select message from message) ").execute();
        conn.close();
    }catch (Exception ex) {
        ex.printStackTrace();
    }
}

Aucun commentaire:

Enregistrer un commentaire