public static function instance($connectionStringOrConnectionName=null)
	{
		$config = Config::instance();

		// Is it a connection string or name?
		if (strpos($connectionStringOrConnectionName, '://') === false)	{
			$connectionString = $connectionStringOrConnectionName ?
				$config->getConnection($connectionStringOrConnectionName) :
				$config->getDefaultConnectionString();
		} else {
			$connectionString = $connectionStringOrConnectionName;
		}	

		if (!$connectionString)	throw new DatabaseException("Empty connection string");

		$info = static::parseConnectionUrl($connectionString);
		$fqclass = static::loadAdapterClass($info->protocol);

		try {
			$connection = new $fqclass($info);
			$connection->protocol = $info->protocol;
			$connection->logging = $config->getLogging();
			$connection->logger = $connection->logging ? $config->getLogger() : null;

			if (isset($info->charset))
				$connection->setEncoding($info->charset);
		} catch (PDOException $e) {
			throw new DatabaseException($e);
		}
		return $connection;
	}