On Mar 10, 1:02 am, "David Crawshaw" <[EMAIL PROTECTED]> wrote:
> 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.

You're right.  I incorrectly assumed, based on how your original stub
was written, that the lock would have been acquired after the first
iteration of the for loop.  Now I'll definitely sleep easier - if I
ever manage to turn this laptop off! ;-)

Thanks,

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

Reply via email to