private function ensureConnected() {
		if ($this->pdo === null) {
			try {
				$this->pdo = new PDO($this->dsn->getDsn(), $this->dsn->getUsername(), $this->dsn->getPassword());
			}
			catch (PDOException $e) {
				ErrorHandler::rethrow($e);
			}

			// iterate over all listeners waiting for the connection to be established
			foreach ($this->onConnectListeners as $onConnectListener) {
				// execute the callback
				$onConnectListener($this);
			}

			// discard the listeners now that they have all been executed
			$this->onConnectListeners = [];

			$this->dsn = null;
		}

		if ($this->driverName === null) {
			$this->driverName = $this->pdo->getAttribute(PDO::ATTR_DRIVER_NAME);
		}
	}