I've been looking into the embeded driver for use within JBoss (or or any environment that has life cycle management) and I have a couple of minor queries.
During initialisation the driver calls this.db = Database.getDatabase(dbname); if db is null then it creates the database calls some other guff and calls configure on the db object. This in turn loads the configuration and calls databases.put(getName(), this); I believe there is a race condition here. If two threads try and create a database then they may end up with seperate objects (one of which is not connected to the master database list. I've been thinking about two solutions. Overload the Database.getDatabase method with a configuration parameter. This would create the database instance in accordance with the config passed. The changes would make the getDatabase methods look something like: public static Database getDatabase(String name) { Database database = (Database) databases.get(name); if (null == database) { // in case it's currently being added (only pay the sync hit on a miss) synchronized (databases) { database = (Database) databases.get(name); } } return database; } public static Database getDatabase(String name, Configuration config) { Database database = (Database) databases.get(name); if (null == database) { // in case it's currently being added (only pay the sync hit on a miss) synchronized (databases) { // was it created while we waited? database = (Database) databases.get(name); if (null == database) { database = new Database(); database.setConfig(config); databases.put(database.getName(), database); } } } return database; } The registration of the database would be removed from database.setConfig() which would mean minor updates to the xmlrpc servlet init method and the embeded driver. These changes should remove the race condition. I'm still a little worried that the embeded driver never seems to get database.close() called. -k.