2. Given positive integers $a, b$ such that $\frac{a^{2}+b^{2}}{a b-1}=k$ $\left(k \in \mathbf{Z}_{+}\right)$. Find the value of $k$.
If $a=b$, then $k=\frac{2 a^{2}}{a^{2}-1}=2+\frac{2}{a^{2}-1}$.
Thus $\left(a^{2}-1\right) \mid 2$, and $a^{2}-1>0$
$\Rightarrow a^{2}-1=1$ or 2.
This contradicts $a \in \mathbf{Z}_{+}$.
Therefore, $a \neq b$.
By symmetry, assume $a>b$.
When $b=1$, $k=\frac{a^{2}+1}{a^{2}-1}=a+1+\frac{2}{a-1}$. Then $(a-1) \mid 2$, and $a \geqslant b+1=2$. Thus, $a=2$ or 3.
In either case, $k=5$.
When $b \geqslant 2$, from $\frac{a^{2}+b^{2}}{a b-1}=k$, we get
$$
a^{2}-k b a+b^{2}+k=0 \text{. }
$$

Deriving a contradiction as in Example 2.
In summary, $k=5$.