[kepler-dev] Database connections

Edward A. Lee eal at eecs.berkeley.edu
Wed Jun 4 12:32:54 PDT 2008


Looking over Efrat's database actors in org.geon, I'm wondering
about whether this design is the best choice.  In particular, he
has an actor OpenDBConnection that produces on its output a
DBConnectionToken. This is provided as an input to DatabaseQuery
and to CloseDBConnection.

This design seems to me to have two problems:

1) If the model fails to fire the CloseDBConnection, either through
modeling error or an exception, then the database connection remains
open.

2) It seems like it would make it awkward to make repeated queries
on the same database, which would seem to be a common situation.

I'm considering an alternative design with:

DatabaseManager: An actor with no input ports or output ports
that opens a connection in preinitialize() and closes it in
wrapup().  Note that wrapup() is guaranteed to be called even
if the model fails with an exception.

DatabaseQuery: An actor with a parameter that references the
DatabaseManager by name and makes queries when fired.


Any comments on the relative merits of these designs?

Edward



------------ 
Edward A. Lee
Chair of EECS and Robert S. Pepper Distinguished Professor
231 Cory Hall, UC Berkeley, Berkeley, CA 94720-1770
phone: 510-642-0253, fax: 510-642-2845
eal at eecs.Berkeley.EDU, http://www.eecs.berkeley.edu/Faculty/Homepages/lee.html  



More information about the Kepler-dev mailing list