@SuppressWarnings("unchecked")
 public <D extends AbstractDAO> D findDAO(Class<D> clazz)
 	throws DBException
 {
  if (null == jdbc)
   throw new DBException("Cannot attach DAO to " + this + ": database not open");
  D dao = (D)daoMap.get(clazz);
  if (null == dao)
  {
    try
    {
     Constructor<?> ctr = clazz.getDeclaredConstructor(this.getClass());
     ctr.setAccessible(true);
     dao = (D) ctr.newInstance(this);
     for (Class<? extends AbstractDAO> dep : dao.dependencies())
      findDAO(dep);
     dao.updateSchema();
     daoMap.put(clazz, dao);
    } catch (NoSuchMethodException e)
    {
     throw new ExceptionInInitializerError("DAO " + clazz
       + " does not have a single argument constructor that accepts a "
       + getClass().getName());
    } catch (InstantiationException e)
    {
     throw new ExceptionInInitializerError("DAO " + clazz + " is abstract");
    } catch (IllegalAccessException e)
    {
     throw (Error) new ExceptionInInitializerError("No access to DAO " + clazz
       + " constructor").initCause(e);
    } catch (InvocationTargetException e)
    {
     throw (Error) new ExceptionInInitializerError(
       "Exception in constructor of DAO " + clazz).initCause(e
       .getTargetException());
    }
  }
  return dao;
 }