diff --git a/core/lib/Drupal/Core/Database/Database.php b/core/lib/Drupal/Core/Database/Database.php
index a799926..06243f2 100644
--- a/core/lib/Drupal/Core/Database/Database.php
+++ b/core/lib/Drupal/Core/Database/Database.php
@@ -7,12 +7,17 @@
 
 namespace Drupal\Core\Database;
 
+use Drupal\Core\Database\Manager\ConnectionInfoPool;
+use Drupal\Core\Database\Manager\DatabaseManager;
+
 /**
  * Primary front-controller for the database system.
  *
  * This class is uninstantiatable and un-extendable. It acts to encapsulate
  * all control and shepherding of database connections into a single location
  * without the use of globals.
+ *
+ * @see \Drupal\Core\Database\Manager\DatabaseManager
  */
 abstract class Database {
 
@@ -40,47 +45,21 @@
   const RETURN_INSERT_ID = 3;
 
   /**
-   * An nested array of all active connections. It is keyed by database name
-   * and target.
-   *
-   * @var array
-   */
-  static protected $connections = array();
-
-  /**
-   * A processed copy of the database connection information from settings.php.
-   *
-   * @var array
-   */
-  static protected $databaseInfo = array();
-
-  /**
-   * A list of key/target credentials to simply ignore.
-   *
-   * @var array
+   * @var \Drupal\Core\Database\Manager\DatabaseManager
    */
-  static protected $ignoreTargets = array();
+  protected static $databaseManager;
 
   /**
-   * The key of the currently active database connection.
+   * Gets the static instance of self::$databaseManager, and lazy-instantiates
+   * it if needed.
    *
-   * @var string
+   * @return \Drupal\Core\Database\Manager\DatabaseManager
    */
-  static protected $activeKey = 'default';
-
-  /**
-   * An array of active query log objects.
-   *
-   * Every connection has one and only one logger object for all targets and
-   * logging keys.
-   *
-   * array(
-   *   '$db_key' => DatabaseLog object.
-   * );
-   *
-   * @var array
-   */
-  static protected $logs = array();
+  public static function getDatabaseManager() {
+    return isset(self::$databaseManager)
+      ? self::$databaseManager
+      : self::$databaseManager = new DatabaseManager(new ConnectionInfoPool());
+  }
 
   /**
    * Starts logging a given logging key on the specified connection.
@@ -98,20 +77,7 @@
    * @see \Drupal\Core\Database\Log
    */
   final public static function startLog($logging_key, $key = 'default') {
-    if (empty(self::$logs[$key])) {
-      self::$logs[$key] = new Log($key);
-
-      // Every target already active for this connection key needs to have the
-      // logging object associated with it.
-      if (!empty(self::$connections[$key])) {
-        foreach (self::$connections[$key] as $connection) {
-          $connection->setLogger(self::$logs[$key]);
-        }
-      }
-    }
-
-    self::$logs[$key]->start($logging_key);
-    return self::$logs[$key];
+    return self::getDatabaseManager()->startLog($logging_key, $key);
   }
 
   /**
@@ -133,12 +99,7 @@
    * @see \Drupal\Core\Database\Log
    */
   final public static function getLog($logging_key, $key = 'default') {
-    if (empty(self::$logs[$key])) {
-      return NULL;
-    }
-    $queries = self::$logs[$key]->get($logging_key);
-    self::$logs[$key]->end($logging_key);
-    return $queries;
+    return self::getDatabaseManager()->getLog($logging_key, $key);
   }
 
   /**
@@ -153,24 +114,7 @@
    *   The corresponding connection object.
    */
   final public static function getConnection($target = 'default', $key = NULL) {
-    if (!isset($key)) {
-      // By default, we want the active connection, set in setActiveConnection.
-      $key = self::$activeKey;
-    }
-    // If the requested target does not exist, or if it is ignored, we fall back
-    // to the default target. The target is typically either "default" or
-    // "replica", indicating to use a replica SQL server if one is available. If
-    // it's not available, then the default/primary server is the correct server
-    // to use.
-    if (!empty(self::$ignoreTargets[$key][$target]) || !isset(self::$databaseInfo[$key][$target])) {
-      $target = 'default';
-    }
-
-    if (!isset(self::$connections[$key][$target])) {
-      // If necessary, a new connection is opened.
-      self::$connections[$key][$target] = self::openConnection($key, $target);
-    }
-    return self::$connections[$key][$target];
+    return self::getDatabaseManager()->getConnection($target, $key);
   }
 
   /**
@@ -184,21 +128,19 @@
    *   otherwise.
    */
   final public static function isActiveConnection() {
-    return !empty(self::$activeKey) && !empty(self::$connections) && !empty(self::$connections[self::$activeKey]);
+    return self::getDatabaseManager()->isActiveConnection();
   }
 
   /**
    * Sets the active connection to the specified key.
    *
-   * @return string|null
+   * @param string $key
+   *
+   * @return null|string
    *   The previous database connection key.
    */
   final public static function setActiveConnection($key = 'default') {
-    if (!empty(self::$databaseInfo[$key])) {
-      $old_key = self::$activeKey;
-      self::$activeKey = $key;
-      return $old_key;
-    }
+    return self::getDatabaseManager()->setActiveConnection($key);
   }
 
   /**
@@ -208,6 +150,9 @@
    *   The database connection information, as defined in settings.php. The
    *   structure of this array depends on the database driver it is connecting
    *   to.
+   *
+   * @return array
+   *   The modified $info array with database connection information.
    */
   final public static function parseConnectionInfo(array $info) {
     // If there is no "driver" property, then we assume it's an array of
@@ -254,9 +199,7 @@
    *   to.
    */
   final public static function addConnectionInfo($key, $target, array $info) {
-    if (empty(self::$databaseInfo[$key][$target])) {
-      self::$databaseInfo[$key][$target] = self::parseConnectionInfo($info);
-    }
+    self::getDatabaseManager()->addConnectionInfo($key, $target, $info);
   }
 
   /**
@@ -265,36 +208,30 @@
    * @param string $key
    *   (optional) The connection key for which to return information.
    *
-   * @return array|null
+   * @return array[]|null
    */
   final public static function getConnectionInfo($key = 'default') {
-    if (!empty(self::$databaseInfo[$key])) {
-      return self::$databaseInfo[$key];
-    }
+    return self::getDatabaseManager()->getConnectionInfo($key);
   }
 
   /**
    * Gets connection information for all available databases.
    *
-   * @return array
+   * @return array[][]
    */
   final public static function getAllConnectionInfo() {
-    return self::$databaseInfo;
+    return self::getDatabaseManager()->getAllConnectionInfo();
   }
 
   /**
    * Sets connection information for multiple databases.
    *
-   * @param array $databases
+   * @param array[][] $databases
    *   A multi-dimensional array specifying database connection parameters, as
    *   defined in settings.php.
    */
   final public static function setMultipleConnectionInfo(array $databases) {
-    foreach ($databases as $key => $targets) {
-      foreach ($targets as $target => $info) {
-        self::addConnectionInfo($key, $target, $info);
-      }
-    }
+    self::getDatabaseManager()->setMultipleConnectionInfo($databases);
   }
 
   /**
@@ -309,22 +246,7 @@
    *   TRUE in case of success, FALSE otherwise.
    */
   final public static function renameConnection($old_key, $new_key) {
-    if (!empty(self::$databaseInfo[$old_key]) && empty(self::$databaseInfo[$new_key])) {
-      // Migrate the database connection information.
-      self::$databaseInfo[$new_key] = self::$databaseInfo[$old_key];
-      unset(self::$databaseInfo[$old_key]);
-
-      // Migrate over the DatabaseConnection object if it exists.
-      if (isset(self::$connections[$old_key])) {
-        self::$connections[$new_key] = self::$connections[$old_key];
-        unset(self::$connections[$old_key]);
-      }
-
-      return TRUE;
-    }
-    else {
-      return FALSE;
-    }
+    return self::getDatabaseManager()->renameConnection($old_key, $new_key);
   }
 
   /**
@@ -337,59 +259,7 @@
    *   TRUE in case of success, FALSE otherwise.
    */
   final public static function removeConnection($key) {
-    if (isset(self::$databaseInfo[$key])) {
-      self::closeConnection(NULL, $key);
-      unset(self::$databaseInfo[$key]);
-      return TRUE;
-    }
-    else {
-      return FALSE;
-    }
-  }
-
-  /**
-   * Opens a connection to the server specified by the given key and target.
-   *
-   * @param string $key
-   *   The database connection key, as specified in settings.php. The default is
-   *   "default".
-   * @param string $target
-   *   The database target to open.
-   *
-   * @throws \Drupal\Core\Database\ConnectionNotDefinedException
-   * @throws \Drupal\Core\Database\DriverNotSpecifiedException
-   */
-  final protected static function openConnection($key, $target) {
-    // If the requested database does not exist then it is an unrecoverable
-    // error.
-    if (!isset(self::$databaseInfo[$key])) {
-      throw new ConnectionNotDefinedException('The specified database connection is not defined: ' . $key);
-    }
-
-    if (!$driver = self::$databaseInfo[$key][$target]['driver']) {
-      throw new DriverNotSpecifiedException('Driver not specified for this database connection: ' . $key);
-    }
-
-    if (!empty(self::$databaseInfo[$key][$target]['namespace'])) {
-      $driver_class = self::$databaseInfo[$key][$target]['namespace'] . '\\Connection';
-    }
-    else {
-      // Fallback for Drupal 7 settings.php.
-      $driver_class = "Drupal\\Core\\Database\\Driver\\{$driver}\\Connection";
-    }
-
-    $pdo_connection = $driver_class::open(self::$databaseInfo[$key][$target]);
-    $new_connection = new $driver_class($pdo_connection, self::$databaseInfo[$key][$target]);
-    $new_connection->setTarget($target);
-    $new_connection->setKey($key);
-
-    // If we have any active logging objects for this connection key, we need
-    // to associate them with the connection we just opened.
-    if (!empty(self::$logs[$key])) {
-      $new_connection->setLogger(self::$logs[$key]);
-    }
-
-    return $new_connection;
+    return self::getDatabaseManager()->removeConnection($key);
   }
 
   /**
@@ -402,30 +272,7 @@
    *   The database connection key. Defaults to NULL which means the active key.
    */
   public static function closeConnection($target = NULL, $key = NULL) {
-    // Gets the active connection by default.
-    if (!isset($key)) {
-      $key = self::$activeKey;
-    }
-    // To close a connection, it needs to be set to NULL and removed from the
-    // static variable. In all cases, closeConnection() might be called for a
-    // connection that was not opened yet, in which case the key is not defined
-    // yet and we just ensure that the connection key is undefined.
-    if (isset($target)) {
-      if (isset(self::$connections[$key][$target])) {
-        self::$connections[$key][$target]->destroy();
-        self::$connections[$key][$target] = NULL;
-      }
-      unset(self::$connections[$key][$target]);
-    }
-    else {
-      if (isset(self::$connections[$key])) {
-        foreach (self::$connections[$key] as $target => $connection) {
-          self::$connections[$key][$target]->destroy();
-          self::$connections[$key][$target] = NULL;
-        }
-      }
-      unset(self::$connections[$key]);
-    }
+    self::getDatabaseManager()->closeConnection($target, $key);
   }
 
   /**
@@ -441,6 +288,6 @@ public static function closeConnection($target = NULL, $key = NULL) {
    *   The target of the specified key to ignore.
    */
   public static function ignoreTarget($key, $target) {
-    self::$ignoreTargets[$key][$target] = TRUE;
+    self::getDatabaseManager()->ignoreTarget($key, $target);
   }
 }
diff --git a/core/lib/Drupal/Core/Database/Manager/ConnectionInfo.php b/core/lib/Drupal/Core/Database/Manager/ConnectionInfo.php
new file mode 100644
index 0000000..fbd1133
--- /dev/null
+++ b/core/lib/Drupal/Core/Database/Manager/ConnectionInfo.php
@@ -0,0 +1,72 @@
+<?php
+
+
+namespace Drupal\Core\Database\Manager;
+
+use Drupal\Core\Database\Database;
+use Drupal\Core\Database\DriverNotSpecifiedException;
+
+/**
+ * Encapsulates connection information for a single database.
+ */
+class ConnectionInfo {
+
+  /**
+   * @var array
+   */
+  private $info;
+
+  /**
+   * @param array $info
+   *
+   * @return self
+   */
+  public static function createFromInfoArray(array $info) {
+    $info = Database::parseConnectionInfo($info);
+    return new self($info);
+  }
+
+  /**
+   * @param array $info
+   *   Normalized $info array.
+   */
+  public function __construct($info) {
+    $this->info = $info;
+  }
+
+  /**
+   * @return array
+   */
+  public function toArray() {
+    return $this->info;
+  }
+
+  /**
+   * @return \Drupal\Core\Database\Connection
+   */
+  public function openConnection() {
+    $driver_class = $this->getDriverClass();
+
+    /** @var \Drupal\Core\Database\Connection $driver_class */
+    $pdo_connection = $driver_class::open($this->info);
+
+    return new $driver_class($pdo_connection, $this->info);
+  }
+
+  /**
+   * @return string
+   */
+  public function getDriverClass() {
+
+    if (!empty($this->info['namespace'])) {
+      return $this->info['namespace'] . '\\Connection';
+    }
+
+    if (!empty($this->info['driver'])) {
+      return 'Drupal\Core\Database\Driver\\' . $this->info['driver'] . '\Connection';
+    }
+
+    throw new DriverNotSpecifiedException('Driver not specified for this database connection.');
+  }
+
+}
diff --git a/core/lib/Drupal/Core/Database/Manager/ConnectionInfoPool.php b/core/lib/Drupal/Core/Database/Manager/ConnectionInfoPool.php
new file mode 100644
index 0000000..e8f80d2
--- /dev/null
+++ b/core/lib/Drupal/Core/Database/Manager/ConnectionInfoPool.php
@@ -0,0 +1,186 @@
+<?php
+
+
+namespace Drupal\Core\Database\Manager;
+
+use Drupal\Core\Database\ConnectionNotDefinedException;
+
+/**
+ * Manages ConnectionInfo objects.
+ */
+class ConnectionInfoPool {
+
+  /**
+   * Processed database connection information from settings.php, wrapped in
+   * ConnectionInfo objects.
+   *
+   * @var ConnectionInfo[][]
+   *   Format: $[$key][$target] instanceof ConnectionInfo
+   */
+  protected $databaseInfo = array();
+
+  /**
+   * @param string $key
+   * @param string $target
+   *
+   * @return bool
+   */
+  public function targetExists($key, $target) {
+    return isset($this->databaseInfo[$key][$target]);
+  }
+
+  /**
+   * @param string $key
+   *
+   * @return bool
+   */
+  public function keyExists($key) {
+    return !empty($this->databaseInfo[$key]);
+  }
+
+  /**
+   * Adds database connection information for a given key/target.
+   *
+   * This method allows to add new connections at runtime.
+   *
+   * Under normal circumstances the preferred way to specify database
+   * credentials is via settings.php. However, this method allows them to be
+   * added at arbitrary times, such as during unit tests, when connecting to
+   * admin-defined third party databases, etc.
+   *
+   * If the given key/target pair already exists, this method will be ignored.
+   *
+   * @param string $key
+   *   The database key.
+   * @param string $target
+   *   The database target name.
+   * @param array $info
+   *   The database connection information, as defined in settings.php. The
+   *   structure of this array depends on the database driver it is connecting
+   *   to.
+   */
+  public function addConnectionInfo($key, $target, array $info) {
+    if (empty($this->databaseInfo[$key][$target])) {
+      $infoObject = ConnectionInfo::createFromInfoArray($info);
+      $this->databaseInfo[$key][$target] = $infoObject;
+    }
+  }
+
+  /**
+   * Gets information on the specified database connection.
+   *
+   * @param string $key
+   *   (optional) The connection key for which to return information.
+   *
+   * @return array[]|null
+   *   Format: $[$target] = $info
+   */
+  public function getConnectionInfo($key = 'default') {
+    if (empty($this->databaseInfo[$key])) {
+      return NULL;
+    }
+    $targets = array();
+    foreach ($this->databaseInfo[$key] as $target => $infoObject) {
+      $targets[$target] = $infoObject->toArray();
+    }
+    return $targets;
+  }
+
+  /**
+   * Gets connection information for all available databases.
+   *
+   * @return array[][]
+   */
+  public function getAllConnectionInfo() {
+    $all = array();
+    foreach ($this->databaseInfo as $key => $targets) {
+      foreach ($targets as $target => $infoObject) {
+        $all[$key][$target] = $infoObject->toArray();
+      }
+    }
+    return $all;
+  }
+
+  /**
+   * Sets connection information for multiple databases.
+   *
+   * @param array[][] $databases
+   *   A multi-dimensional array specifying database connection parameters, as
+   *   defined in settings.php.
+   */
+  public function setMultipleConnectionInfo(array $databases) {
+    foreach ($databases as $key => $targets) {
+      foreach ($targets as $target => $info) {
+        $this->addConnectionInfo($key, $target, $info);
+      }
+    }
+  }
+
+  /**
+   * Rename a connection and its corresponding connection information.
+   *
+   * @param string $old_key
+   *   The old connection key.
+   * @param string $new_key
+   *   The new connection key.
+   *
+   * @return bool
+   *   TRUE in case of success, FALSE otherwise.
+   */
+  public function renameConnection($old_key, $new_key) {
+    if (!empty($this->databaseInfo[$old_key]) && empty($this->databaseInfo[$new_key])) {
+      // Migrate the database connection information.
+      $this->databaseInfo[$new_key] = $this->databaseInfo[$old_key];
+      unset($this->databaseInfo[$old_key]);
+
+      return TRUE;
+    }
+    else {
+      return FALSE;
+    }
+  }
+
+  /**
+   * Remove a connection and its corresponding connection information.
+   *
+   * @param string $key
+   *   The connection key.
+   *
+   * @return bool
+   *   TRUE in case of success, FALSE otherwise.
+   */
+  public function removeConnection($key) {
+    if (isset($this->databaseInfo[$key])) {
+      unset($this->databaseInfo[$key]);
+      return TRUE;
+    }
+    else {
+      return FALSE;
+    }
+  }
+
+  /**
+   * @param string $key
+   *   The database connection key, as specified in settings.php. The default is
+   *   "default".
+   * @param string $target
+   *   The database target to open.
+   *
+   * @return \Drupal\Core\Database\Manager\ConnectionInfo
+   *
+   * @throws \Drupal\Core\Database\ConnectionNotDefinedException
+   */
+  public function requireConnectionInfo($key, $target) {
+
+    if (isset($this->databaseInfo[$key][$target])) {
+      return $this->databaseInfo[$key][$target];
+    }
+
+    if (!isset($this->databaseInfo[$key])) {
+      throw new ConnectionNotDefinedException('The specified database connection is not defined: ' . $key);
+    }
+
+    throw new ConnectionNotDefinedException('The specified database connection target is not defined: ' . $key . ' / ' . $target);
+  }
+
+}
diff --git a/core/lib/Drupal/Core/Database/Database.php b/core/lib/Drupal/Core/Database/Manager/DatabaseManager.php
similarity index 50%
copy from core/lib/Drupal/Core/Database/Database.php
copy to core/lib/Drupal/Core/Database/Manager/DatabaseManager.php
index a799926..52247a8 100644
--- a/core/lib/Drupal/Core/Database/Database.php
+++ b/core/lib/Drupal/Core/Database/Manager/DatabaseManager.php
@@ -1,72 +1,48 @@
 <?php
 
-/**
- * @file
- * Definition of Drupal\Core\Database\Database
- */
 
-namespace Drupal\Core\Database;
+namespace Drupal\Core\Database\Manager;
+
+use Drupal\Core\Database\Log;
 
 /**
- * Primary front-controller for the database system.
+ * Object to manage one or more database connections used in a system.
  *
- * This class is uninstantiatable and un-extendable. It acts to encapsulate
- * all control and shepherding of database connections into a single location
- * without the use of globals.
+ * @see \Drupal\Core\Database\Database
  */
-abstract class Database {
-
-  /**
-   * Flag to indicate a query call should simply return NULL.
-   *
-   * This is used for queries that have no reasonable return value anyway, such
-   * as INSERT statements to a table without a serial primary key.
-   */
-  const RETURN_NULL = 0;
-
-  /**
-   * Flag to indicate a query call should return the prepared statement.
-   */
-  const RETURN_STATEMENT = 1;
-
-  /**
-   * Flag to indicate a query call should return the number of affected rows.
-   */
-  const RETURN_AFFECTED = 2;
-
-  /**
-   * Flag to indicate a query call should return the "last insert id".
-   */
-  const RETURN_INSERT_ID = 3;
+class DatabaseManager {
 
   /**
    * An nested array of all active connections. It is keyed by database name
    * and target.
    *
-   * @var array
+   * @var \Drupal\Core\Database\Connection[][]
+   *   Format: $[$key][$target] = $connection
    */
-  static protected $connections = array();
+  protected $connections = array();
 
   /**
-   * A processed copy of the database connection information from settings.php.
+   * Processed database connection information from settings.php, wrapped in
+   * ConnectionInfo objects.
    *
-   * @var array
+   * @var ConnectionInfoPool
    */
-  static protected $databaseInfo = array();
+  protected $connectionInfoPool = array();
 
   /**
    * A list of key/target credentials to simply ignore.
    *
-   * @var array
+   * @var bool[][]
+   *   Format: $[$key][$target] = TRUE
    */
-  static protected $ignoreTargets = array();
+  protected $ignoreTargets = array();
 
   /**
    * The key of the currently active database connection.
    *
    * @var string
    */
-  static protected $activeKey = 'default';
+  protected $activeKey = 'default';
 
   /**
    * An array of active query log objects.
@@ -74,13 +50,19 @@
    * Every connection has one and only one logger object for all targets and
    * logging keys.
    *
-   * array(
-   *   '$db_key' => DatabaseLog object.
-   * );
+   * @var \Drupal\Core\Database\Log[]
+   *   Format: $[$db_key] = $log
+   */
+  protected $logs = array();
+
+  /**
+   * Constructs a DatabaseManager object.
    *
-   * @var array
+   * @param \Drupal\Core\Database\Manager\ConnectionInfoPool $connection_info_pool
    */
-  static protected $logs = array();
+  public function __construct(ConnectionInfoPool $connection_info_pool) {
+    $this->connectionInfoPool = $connection_info_pool;
+  }
 
   /**
    * Starts logging a given logging key on the specified connection.
@@ -97,21 +79,21 @@
    *
    * @see \Drupal\Core\Database\Log
    */
-  final public static function startLog($logging_key, $key = 'default') {
-    if (empty(self::$logs[$key])) {
-      self::$logs[$key] = new Log($key);
+  public function startLog($logging_key, $key = 'default') {
+    if (empty($this->logs[$key])) {
+      $this->logs[$key] = new Log($key);
 
       // Every target already active for this connection key needs to have the
       // logging object associated with it.
-      if (!empty(self::$connections[$key])) {
-        foreach (self::$connections[$key] as $connection) {
-          $connection->setLogger(self::$logs[$key]);
+      if (!empty($this->connections[$key])) {
+        foreach ($this->connections[$key] as $connection) {
+          $connection->setLogger($this->logs[$key]);
         }
       }
     }
 
-    self::$logs[$key]->start($logging_key);
-    return self::$logs[$key];
+    $this->logs[$key]->start($logging_key);
+    return $this->logs[$key];
   }
 
   /**
@@ -132,12 +114,12 @@
    *
    * @see \Drupal\Core\Database\Log
    */
-  final public static function getLog($logging_key, $key = 'default') {
-    if (empty(self::$logs[$key])) {
+  public function getLog($logging_key, $key = 'default') {
+    if (empty($this->logs[$key])) {
       return NULL;
     }
-    $queries = self::$logs[$key]->get($logging_key);
-    self::$logs[$key]->end($logging_key);
+    $queries = $this->logs[$key]->get($logging_key);
+    $this->logs[$key]->end($logging_key);
     return $queries;
   }
 
@@ -152,25 +134,25 @@
    * @return \Drupal\Core\Database\Connection
    *   The corresponding connection object.
    */
-  final public static function getConnection($target = 'default', $key = NULL) {
+  public function getConnection($target = 'default', $key = NULL) {
+
     if (!isset($key)) {
       // By default, we want the active connection, set in setActiveConnection.
-      $key = self::$activeKey;
+      $key = $this->activeKey;
     }
+
     // If the requested target does not exist, or if it is ignored, we fall back
     // to the default target. The target is typically either "default" or
     // "replica", indicating to use a replica SQL server if one is available. If
     // it's not available, then the default/primary server is the correct server
     // to use.
-    if (!empty(self::$ignoreTargets[$key][$target]) || !isset(self::$databaseInfo[$key][$target])) {
+    if (!empty($this->ignoreTargets[$key][$target]) || !$this->connectionInfoPool->targetExists($key, $target)) {
       $target = 'default';
     }
 
-    if (!isset(self::$connections[$key][$target])) {
-      // If necessary, a new connection is opened.
-      self::$connections[$key][$target] = self::openConnection($key, $target);
-    }
-    return self::$connections[$key][$target];
+    return isset($this->connections[$key][$target])
+      ? $this->connections[$key][$target]
+      : $this->connections[$key][$target] = $this->openConnection($key, $target);
   }
 
   /**
@@ -183,53 +165,28 @@
    *   TRUE if there is at least one database connection established, FALSE
    *   otherwise.
    */
-  final public static function isActiveConnection() {
-    return !empty(self::$activeKey) && !empty(self::$connections) && !empty(self::$connections[self::$activeKey]);
+  public function isActiveConnection() {
+    return !empty($this->activeKey)
+      && !empty($this->connections)
+      && !empty($this->connections[$this->activeKey]);
   }
 
   /**
    * Sets the active connection to the specified key.
    *
+   * @param string $key
+   *
    * @return string|null
    *   The previous database connection key.
    */
-  final public static function setActiveConnection($key = 'default') {
-    if (!empty(self::$databaseInfo[$key])) {
-      $old_key = self::$activeKey;
-      self::$activeKey = $key;
+  public function setActiveConnection($key = 'default') {
+    if ($this->connectionInfoPool->keyExists($key)) {
+      $old_key = $this->activeKey;
+      $this->activeKey = $key;
       return $old_key;
     }
-  }
 
-  /**
-   * Process the configuration file for database information.
-   *
-   * @param array $info
-   *   The database connection information, as defined in settings.php. The
-   *   structure of this array depends on the database driver it is connecting
-   *   to.
-   */
-  final public static function parseConnectionInfo(array $info) {
-    // If there is no "driver" property, then we assume it's an array of
-    // possible connections for this target. Pick one at random. That allows
-    // us to have, for example, multiple replica servers.
-    if (empty($info['driver'])) {
-      $info = $info[mt_rand(0, count($info) - 1)];
-    }
-    // Parse the prefix information.
-    if (!isset($info['prefix'])) {
-      // Default to an empty prefix.
-      $info['prefix'] = array(
-        'default' => '',
-      );
-    }
-    elseif (!is_array($info['prefix'])) {
-      // Transform the flat form into an array form.
-      $info['prefix'] = array(
-        'default' => $info['prefix'],
-      );
-    }
-    return $info;
+    return NULL;
   }
 
   /**
@@ -253,10 +210,8 @@
    *   structure of this array depends on the database driver it is connecting
    *   to.
    */
-  final public static function addConnectionInfo($key, $target, array $info) {
-    if (empty(self::$databaseInfo[$key][$target])) {
-      self::$databaseInfo[$key][$target] = self::parseConnectionInfo($info);
-    }
+  public function addConnectionInfo($key, $target, array $info) {
+    $this->connectionInfoPool->addConnectionInfo($key, $target, $info);
   }
 
   /**
@@ -265,36 +220,31 @@
    * @param string $key
    *   (optional) The connection key for which to return information.
    *
-   * @return array|null
+   * @return array[]|null
+   *   Format: $[$target] = $info
    */
-  final public static function getConnectionInfo($key = 'default') {
-    if (!empty(self::$databaseInfo[$key])) {
-      return self::$databaseInfo[$key];
-    }
+  public function getConnectionInfo($key = 'default') {
+    return $this->connectionInfoPool->getConnectionInfo($key);
   }
 
   /**
    * Gets connection information for all available databases.
    *
-   * @return array
+   * @return array[][]
    */
-  final public static function getAllConnectionInfo() {
-    return self::$databaseInfo;
+  public function getAllConnectionInfo() {
+    return $this->connectionInfoPool->getAllConnectionInfo();
   }
 
   /**
    * Sets connection information for multiple databases.
    *
-   * @param array $databases
+   * @param array[][] $databases
    *   A multi-dimensional array specifying database connection parameters, as
    *   defined in settings.php.
    */
-  final public static function setMultipleConnectionInfo(array $databases) {
-    foreach ($databases as $key => $targets) {
-      foreach ($targets as $target => $info) {
-        self::addConnectionInfo($key, $target, $info);
-      }
-    }
+  public function setMultipleConnectionInfo(array $databases) {
+    $this->connectionInfoPool->setMultipleConnectionInfo($databases);
   }
 
   /**
@@ -308,16 +258,12 @@
    * @return bool
    *   TRUE in case of success, FALSE otherwise.
    */
-  final public static function renameConnection($old_key, $new_key) {
-    if (!empty(self::$databaseInfo[$old_key]) && empty(self::$databaseInfo[$new_key])) {
-      // Migrate the database connection information.
-      self::$databaseInfo[$new_key] = self::$databaseInfo[$old_key];
-      unset(self::$databaseInfo[$old_key]);
-
+  public function renameConnection($old_key, $new_key) {
+    if ($this->connectionInfoPool->renameConnection($old_key, $new_key)) {
       // Migrate over the DatabaseConnection object if it exists.
-      if (isset(self::$connections[$old_key])) {
-        self::$connections[$new_key] = self::$connections[$old_key];
-        unset(self::$connections[$old_key]);
+      if (isset($this->connections[$old_key])) {
+        $this->connections[$new_key] = $this->connections[$old_key];
+        unset($this->connections[$old_key]);
       }
 
       return TRUE;
@@ -336,10 +282,9 @@
    * @return bool
    *   TRUE in case of success, FALSE otherwise.
    */
-  final public static function removeConnection($key) {
-    if (isset(self::$databaseInfo[$key])) {
-      self::closeConnection(NULL, $key);
-      unset(self::$databaseInfo[$key]);
+  public function removeConnection($key) {
+    if ($this->connectionInfoPool->removeConnection($key)) {
+      $this->closeConnection(NULL, $key);
       return TRUE;
     }
     else {
@@ -356,37 +301,23 @@
    * @param string $target
    *   The database target to open.
    *
+   * @return \Drupal\Core\Database\Connection
+   *   The newly opened database connection.
+   *
    * @throws \Drupal\Core\Database\ConnectionNotDefinedException
    * @throws \Drupal\Core\Database\DriverNotSpecifiedException
    */
-  final protected static function openConnection($key, $target) {
-    // If the requested database does not exist then it is an unrecoverable
-    // error.
-    if (!isset(self::$databaseInfo[$key])) {
-      throw new ConnectionNotDefinedException('The specified database connection is not defined: ' . $key);
-    }
+  protected function openConnection($key, $target) {
+    $info = $this->connectionInfoPool->requireConnectionInfo($key, $target);
 
-    if (!$driver = self::$databaseInfo[$key][$target]['driver']) {
-      throw new DriverNotSpecifiedException('Driver not specified for this database connection: ' . $key);
-    }
-
-    if (!empty(self::$databaseInfo[$key][$target]['namespace'])) {
-      $driver_class = self::$databaseInfo[$key][$target]['namespace'] . '\\Connection';
-    }
-    else {
-      // Fallback for Drupal 7 settings.php.
-      $driver_class = "Drupal\\Core\\Database\\Driver\\{$driver}\\Connection";
-    }
-
-    $pdo_connection = $driver_class::open(self::$databaseInfo[$key][$target]);
-    $new_connection = new $driver_class($pdo_connection, self::$databaseInfo[$key][$target]);
+    $new_connection = $info->openConnection();
     $new_connection->setTarget($target);
     $new_connection->setKey($key);
 
     // If we have any active logging objects for this connection key, we need
     // to associate them with the connection we just opened.
-    if (!empty(self::$logs[$key])) {
-      $new_connection->setLogger(self::$logs[$key]);
+    if (!empty($this->logs[$key])) {
+      $new_connection->setLogger($this->logs[$key]);
     }
 
     return $new_connection;
@@ -401,30 +332,30 @@
    * @param string $key
    *   The database connection key. Defaults to NULL which means the active key.
    */
-  public static function closeConnection($target = NULL, $key = NULL) {
+  public function closeConnection($target = NULL, $key = NULL) {
     // Gets the active connection by default.
     if (!isset($key)) {
-      $key = self::$activeKey;
+      $key = $this->activeKey;
     }
     // To close a connection, it needs to be set to NULL and removed from the
-    // static variable. In all cases, closeConnection() might be called for a
+    // variable. In all cases, closeConnection() might be called for a
     // connection that was not opened yet, in which case the key is not defined
     // yet and we just ensure that the connection key is undefined.
     if (isset($target)) {
-      if (isset(self::$connections[$key][$target])) {
-        self::$connections[$key][$target]->destroy();
-        self::$connections[$key][$target] = NULL;
+      if (isset($this->connections[$key][$target])) {
+        $this->connections[$key][$target]->destroy();
+        $this->connections[$key][$target] = NULL;
       }
-      unset(self::$connections[$key][$target]);
+      unset($this->connections[$key][$target]);
     }
     else {
-      if (isset(self::$connections[$key])) {
-        foreach (self::$connections[$key] as $target => $connection) {
-          self::$connections[$key][$target]->destroy();
-          self::$connections[$key][$target] = NULL;
+      if (isset($this->connections[$key])) {
+        foreach ($this->connections[$key] as $target => $connection) {
+          $this->connections[$key][$target]->destroy();
+          $this->connections[$key][$target] = NULL;
         }
       }
-      unset(self::$connections[$key]);
+      unset($this->connections[$key]);
     }
   }
 
@@ -440,7 +371,8 @@ public static function closeConnection($target = NULL, $key = NULL) {
    * @param string $target
    *   The target of the specified key to ignore.
    */
-  public static function ignoreTarget($key, $target) {
-    self::$ignoreTargets[$key][$target] = TRUE;
+  public function ignoreTarget($key, $target) {
+    $this->ignoreTargets[$key][$target] = TRUE;
   }
+
 }
