private function connect()
    {
        $dsn = "{$this->credentials->getDriver()}:host={$this->credentials->getHost()}";

        try {
            $pdo = new \PDO($dsn, $this->credentials->getUsername(), $this->credentials->getPassword());
        } catch (\PDOException $e) {
            throw new \RuntimeException('Failed to connect to database.', 0, $e);
        }

        $this->pdo = $pdo;

        if (null !== $this->credentials->getCharset()) {
            $this->setCharset($this->credentials->getCharset());
        }

        if (null !== $this->credentials->getDatabase()) {
            $this->selectDatabase($this->credentials->getDatabase());
        }
    }