It can be solved using differentiation under the integral sign. Consider the following integral:
\begin{equation}
I(t)=\int\limits_{-\infty}^{+\infty} \frac{\cos(tx)}{x^{2}+k} \,dx = 2\int\limits_{0}^{+\infty} \frac{\cos(tx)}{x^{2}+k} \,dx
\end{equation}
for any positive real $t$ and $k$. The first derivative with respect to $t$ is:
\begin{equation}
I'(t)= -2\int\limits_{0}^{+\infty} \frac{x\sin(tx)}{x^{2}+k} \,dx
\end{equation}
\begin{equation}
\Leftrightarrow \hspace{.3cm}I'(t)= -2\int\limits_{0}^{+\infty} \frac{x^{2}\sin(tx)}{x(x^{2}+k)} \,dx
\end{equation}
\begin{equation}
\Leftrightarrow \hspace{.3cm}I'(t)= -2\int\limits_{0}^{+\infty} \frac{(x^{2}+k-k)\sin(tx)}{x(x^{2}+k)} \,dx
\end{equation}
\begin{equation}
\Leftrightarrow \hspace{.3cm}I'(t)= -2\int\limits_{0}^{+\infty} \frac{\sin(tx)}{x} \,dx +2k\int\limits_{0}^{+\infty} \frac{\sin(tx)}{x(x^{2}+k)} \,dx
\end{equation}
The first one is just the sine integral as $x\rightarrow \infty$ and it is known to converge to $\frac{\pi}{2}$. Thus:
\begin{equation}
I'(t)= 2k\int\limits_{0}^{+\infty} \frac{\sin(tx)}{x(x^{2}+k)} \,dx -\pi
\end{equation}
Differentiating once more with respect to $t$ yields:
\begin{equation}
I''(t)= 2k\int\limits_{0}^{+\infty} \frac{\cos(tx)}{x^{2}+k} \,dx
\end{equation}
\begin{equation}
\Leftrightarrow \hspace{.3cm}I''(t)-kI(t)=0
\end{equation}
The general solution to the ODE is:
\begin{equation}
I(t)=c_{1}e^{\sqrt{k}t}+c_{2}e^{-\sqrt{k}t}
\end{equation}
Plugging some conditions $\left(I(t=0) \,\,\text{and}\,\, I'(t=0)\right)$ allows you to find that $c_{1}=0$ and that $c_{2}=\frac{\pi}{\sqrt{k}}$. Then:
\begin{equation}
\boxed{\int\limits_{-\infty}^{+\infty} \frac{\cos(tx)}{x^{2}+k} \,dx = \frac{\pi}{\sqrt{k}}e^{-\sqrt{k}t}}
\end{equation}
for positive real values of $t$ and $k$. If you plug $t=2$ and $k=4$, you obtain the desired result.
Best Answer
Of course, $\cos(x)$ is even, so you can omit the negative sign in its argument. Consider the integral
$$I=\oint_C\underbrace{\frac{ze^{iz}}{z^2-2z+5}}_{f(z)}\,\mathrm dz$$
over the contour $C$ composed of (1) $\Gamma$, the semicircle centered at the origin with radius $R$, and (2) the line segment joining $-R$ and $R$ on the real axis. It's easy to show the integral along $\Gamma$ vanishes as $R\to\infty$:
$$\left|\int_\Gamma f(z)\,\mathrm dz\right| = \left|\int_0^\pi f(Re^{it})iRe^{it}\,\mathrm dt\right|\le\frac{\pi R^2e^{-R\sin t}}{\left|R-\sqrt 5\right|^2}\stackrel{R\to\infty}\to0$$
Meanwhile, the remaining integral over $[-R,R]$ converges to the integral you want to find.
$f(z)$ has poles at
$$z^2-2z+5=(z-1)^2+4=0 \implies z=1\pm2i$$
with $z=1+2i$ the only pole in the interior of $C$, so by the residue theorem,
$$I=2\pi i\operatorname{Res}\left(f(z),z=1+2i\right)=2\pi i\frac{(1+2i)e^{\frac{i\pi}2(1+2i)}}{4i}=-\pi e^{-\pi}+\frac{\pi e^{-\pi}}2i$$
and the real part corresponds to your original integral, so its value is $\boxed{-\pi e^{-\pi}}$.