empire-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Harald Kirsch <harald.kir...@raytion.com>
Subject DBDatabase object usable by multiple threads
Date Sat, 18 Oct 2014 15:47:12 GMT
Looking at the implementation of open() in DBDatabase, it does not look like this is thread
save, because whichever thread happens to be last, wins in opening the database for its combination
of DBDatabaseDriver and JDBC Connection.

Does this mean that in a typical WEB application each request needs it own DBDatabase object
which, when not working with sessions needs to be created from scratch for each request?

As explained in the tutorial, I derive my db schema from DBDatabase and add the tables by
creating them in the constructor. This is (a) non trival code and (b) always creates the exact
same object again, so it seems a bit of a waste to perform the creation over and over again.

Clearly I am missing something. Is DBDatabase thread safe nevertheless?


View raw message