Integration of $\frac{1}{x^2-a^2}$ by trigonometric substitution? 
$$\int \frac{1}{x^2-a^2}dx$$

Now, I know this can be done by splitting the function into two integrable functions,
$\displaystyle\dfrac{1}{2a}\int \bigg(\dfrac{1}{x-a} - \dfrac{1}{x+a}\bigg)dx$
And then doing the usual stuff.
My question is, how can we do this by using trigonometric substitution?
The only thing that gets in my mind is $x=a\sec\theta$, but then got stuck on proceeding further.
Any help would be appreciated.
 A: In addition to other answers: for $x > a$ a substitution $$x = a \cosh(x)$$ seems appropriate. The rest of the solution should work just the same.
A: We have
$$I=\int \frac{1}{x^2-a^2}dx$$
Let $x=a\cos\theta$, then $dx=-a\sin\theta d\theta$.
\begin{align}
I
&= \int \frac{1}{x^2-a^2}dx \\
&= \int \frac{-a\sin\theta}{a^2(\cos^2\theta-1)}d\theta \\
&=\int \frac{-a\sin\theta}{-a^2\sin^2\theta}d\theta \\
&= \frac1a\int \csc\theta d\theta \\
&= -\frac1a\ln\left\lvert\csc\theta+\cot\theta\right\rvert +C\\
&= -\frac1a\ln\left\lvert\frac{1}{\sin\theta}+\frac{\cos\theta}{\sin\theta}\right\rvert +C\\
&= -\frac1a\ln\left\lvert\frac{1+x/a}{\pm\sqrt{1-x^2/a^2}}\right\rvert +C\\
&= -\frac1a\ln\left\lvert\frac{\sqrt{1+x/a}\sqrt{1+x/a}}{\sqrt{1-x/a}\sqrt{1+x/a}}\right\rvert +C\\
&= -\frac1{2a}\ln\left\lvert\frac{1+x/a}{1-x/a}\right\rvert +C\\
&= -\frac1{2a}\ln\left\lvert\frac{a+x}{a-x}\right\rvert +C\\
\end{align}
A: You might use $x=a\sec\theta$: $dx=a\sec\theta\tan\theta\,d\theta$ and the integral becomes
$$
\int\frac{1}{a^2(\sec^2\theta-1)}a\sec\theta\tan\theta\,d\theta
=
\frac{1}{a}\int\frac{\cos^2\theta}{\sin^2\theta}\frac{1}{\cos\theta}\frac{\sin\theta}{\cos\theta}\,d\theta
=
\frac{1}{a}\int\frac{1}{\sin\theta}\,d\theta
$$
and this is a known fellow: set $\theta=2u$, so the integral becomes (leaving aside the factor $1/a$):
$$
\int\frac{1}{\sin u\cos u}\,du=
\int\frac{1}{\cos^2u+\sin^2u}{\sin u\cos u}\,du=
\int\frac{\cos u}{\sin u}\,du+\int\frac{\sin u}{\cos u}\,du
$$
You thus get
$$
\log\lvert\sin u\rvert-\log\lvert\cos u\rvert+c=
\log\left\lvert\tan\frac{\theta}{2}\right\rvert+c
$$
Now back substitute.
Oh, well, but if we do $x=a\cos t$, instead?
$$
\int\frac{1}{a^2(\cos^2t-1)}(-a\sin t)\,dt=
\frac{1}{a}\int\frac{1}{\sin t}\,dt
$$
Speedier, isn't it? Anyway, not easier than observing that
$$
\frac{1}{x^2-a^2}=\frac{1}{2a}\left(\frac{1}{x-a}-\frac{1}{x+a}\right)
$$
