public DLNAMediaDatabase(String name) {
    String dir = "database";
    dbName = name;
    File fileDir = new File(dir);

    if (Platform.isWindows()) {
      String profileDir = configuration.getProfileDirectory();
      url = String.format("jdbc:h2:%s\\%s/%s", profileDir, dir, dbName);
      fileDir = new File(profileDir, dir);
    } else {
      url = Constants.START_URL + dir + "/" + dbName;
    }
    dbDir = fileDir.getAbsolutePath();
    LOGGER.debug("Using database URL: " + url);
    LOGGER.info("Using database located at: " + dbDir);

    try {
      Class.forName("org.h2.Driver");
    } catch (ClassNotFoundException e) {
      LOGGER.error(null, e);
    }

    JdbcDataSource ds = new JdbcDataSource();
    ds.setURL(url);
    ds.setUser("sa");
    ds.setPassword("");
    cp = JdbcConnectionPool.create(ds);
  }
  /** Returns a data source for the HSQL database. */
  protected DataSource createDataSource() throws SQLException {
    DataSource candidate = super.createDataSource();
    if (candidate instanceof JdbcDataSource) {
      return candidate;
    }
    final JdbcDataSource source = new JdbcDataSource();
    File directory = getDirectory();
    if (directory != null) {
      /*
       * Constructs the full path to the HSQL database. Note: we do not use
       * File.toURI() because HSQL doesn't seem to expect an encoded URL
       * (e.g. "%20" instead of spaces).
       */
      final StringBuilder url = new StringBuilder(PREFIX);
      final String path = directory.getAbsolutePath().replace(File.separatorChar, '/');
      if (path.length() == 0 || path.charAt(0) != '/') {
        url.append('/');
      }
      url.append(path);

      if (url.charAt(url.length() - 1) != '/') {
        url.append('/');
      }
      url.append(DATABASE_NAME);
      // no need for validation query, saves some work
      url.append(";AUTO_RECONNECT=TRUE;CACHE_SIZE=131072;CACHE_TYPE=TQ");
      source.setURL((url.toString()));
      source.setUser("sa");
      source.setPassword("");
      assert directory.equals(getDirectory(source)) : url;
    }
    /*
     * If the temporary directory do not exists or can't be created, lets the 'database'
     * attribute unset. If the user do not set it explicitly (through JNDI or by overrding
     * this method), an exception will be thrown when 'createBackingStore()' will be invoked.
     */
    source.setUser("SA"); // System administrator. No password.
    return source;
  }
  public DLNAMediaDatabase(String name) {
    dbName = name;
    File profileDirectory = new File(configuration.getProfileDirectory());
    dbDir =
        new File(
                profileDirectory.isDirectory() ? configuration.getProfileDirectory() : null,
                "database")
            .getAbsolutePath();
    url = Constants.START_URL + dbDir + File.separator + dbName;
    LOGGER.debug("Using database URL: " + url);
    LOGGER.info("Using database located at: " + dbDir);

    try {
      Class.forName("org.h2.Driver");
    } catch (ClassNotFoundException e) {
      LOGGER.error(null, e);
    }

    JdbcDataSource ds = new JdbcDataSource();
    ds.setURL(url);
    ds.setUser("sa");
    ds.setPassword("");
    cp = JdbcConnectionPool.create(ds);
  }