Why can't you make your code look like this:

while(true)
{
  List l = getMediaObjects();
  foreach(MediaFile mf : l)
  {
     log.log("Processing '" + mf.getTitle()); // calls addBatch()
     if(p.shouldExecuteExternalProc(mf))
          executeProc();
    else
      log.log("Not running external proc because..."); // calls addBatch()
  }

  log.log("Sleeping until..."); // calls addBatch
  conn.setAutoCommit(false);
  log.flush(); // calls executeBatch(), db lock happens here
  conn.commit();
  Thread.sleep(x);
}

You see, addBatch() doesn't lock the database. It just stores the
values in memory. The database doesn't get touched until
executeBatch() is called. This way, all of your time consuming work is
done in the loop while the database isn't locked. Then at the end you
create a transaction, execute everything at once (as we decided, a
very fast action with the native driver), and the transaction is
committed.

d.

--~--~---------~--~----~------------~-------~--~----~
Mailing List: http://groups.google.com/group/sqlitejdbc?hl=en
To unsubscribe, send email to [EMAIL PROTECTED]
-~----------~----~----~----~------~----~------~--~---

Reply via email to