private function parseDsn($dsn) {
    $parsed = array();

    $typeEnd = strpos($dsn, ':');
    $dbType = substr($dsn, 0, $typeEnd);
    $parsed['dbtype'] = $dbType;

    $dsn = substr($dsn, $typeEnd+1);

    $parts = explode(';', $dsn);
    foreach($parts as $part) {
      list($key, $val) = explode('=', $part);
      $parsed[$key] = $val;
    }

    return $parsed;
  }