At present, the functions DB.execute() and RS.next() throw a
java.sql.SQLException to indicate a SQLITE_BUSY condition. There are
some cases where a caller might like to catch a more specific
exception to distinguish the SQLITE_BUSY case, as explained in the
SQLite Wiki "Multi Threading" page:

  http://www.sqlite.org/cvstrac/wiki?p=MultiThreading
  (Section "Study case: multithreaded insert on the same database",
   Solution discussion)

Perhaps this could be as simple as:

,----
| package org.sqlite;
| 
| 
| class BusyException extends java.sql.SQLTransientException {
|    /* Forward as many constructors as necessary, though none but
|       the default seem too important. */
| }
`----

However, in cases where a busy timeout has been set by the user¹, it
would be more appropriate to throw a java.sql.SQLTimeoutException upon
encountering a SQLITE_BUSY condition.

It would also be nice to support a user-defined per-Connection "busy
handler" callback to use in lieu of the timeout handler. I'm not sure
how hard it is to wire such a callback between the C API and Java, but
the interface would be rather obvious:

   interface BusyHandler {
      boolean onBusy(int callCount);
   }

Returning true would be equivalent to a non-zero return value for a
C-based busy handler, meaning that the another attempt should be made
to access the database before giving up.

In the meantime, thanks for a great library.


Footnotes: 
¹ Though I do see that the Conn constructor sets the busy timeout to
  3000 ms by default, so we'd need to check if the current
  connection's timeout was less than or equal to 0 to figure out
  whether SQLITE_BUSY arose due to timeout.

    http://www.sqlite.org/capi3ref.html#sqlite3_busy_timeout

-- 
Steven E. Harris

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SQLiteJDBC" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlitejdbc?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to