protected void endIdegaDatabasePool() {
   PoolManager.getInstance().release();
   int count = Thread.activeCount();
   Thread[] threads = new Thread[count];
   Thread.enumerate(threads);
   for (int i = 0; i < threads.length; i++) {
     Thread thread = threads[i];
     String name = (thread == null) ? null : thread.getName();
     // System.out.println(name);
     if (name != null && name.startsWith("HSQLDB")) {
       thread.interrupt();
     }
   }
 }
  /**
   * Returns true if a db.properties file is found and old style idegaWeb PoolManager is
   * initialized.
   */
  protected boolean startIdegaDatabasePool() {
    String separator = File.separator;
    ConnectionBroker.POOL_MANAGER_TYPE = ConnectionBroker.POOL_MANAGER_TYPE_IDEGA;
    String fileName = null;
    String sfile1 =
        this.iwma.getApplicationRealPath() + "/WEB-INF/idegaweb/properties/db.properties";
    String sfile2 = this.iwma.getPropertiesRealPath() + separator + "db.properties";
    String dbPropsFromSystemProperty =
        System.getProperty(ConnectionBroker.SYSTEM_PROPERTY_DB_PROPERTIES_FILE_PATH);
    if (dbPropsFromSystemProperty != null && !"".equals(dbPropsFromSystemProperty)) {
      sfile1 = dbPropsFromSystemProperty;
      log.info(
          "Trying to load db.properties from system property ("
              + ConnectionBroker.SYSTEM_PROPERTY_DB_PROPERTIES_FILE_PATH
              + ") :"
              + dbPropsFromSystemProperty);
    }

    File file1 = new File(sfile1);
    File file2 = new File(sfile2);

    if (file1.exists()) {
      fileName = sfile1;
    } else if (file2.exists()) {
      fileName = sfile2;
    } else {
      log.fine("No db.properties found");
      return false;
    }

    log.info("Reading Databases from file: " + fileName);
    log.fine("Starting idega Datastore ConnectionPool");
    PoolManager.unlock();
    PoolManager.getInstance(fileName, this.iwma);

    return true;
  }