Question: $$x^2\left(\frac{dy}{dx}\right)+2xy=x^2-1$$

Here where I got with this:

$x\cdot\frac{dy}{dx} +2y = x-\frac{1}{x}$

$-2y=x\cdot\frac{dy}{dx} + \frac{1}{x} -x$

Then integrate:

$-y^2+C = \int x\cdot dy+\ln(x)-\frac{1}{2}x^2$

Now I am left with that final integral above, which I am in need of help to solve. Thanks

Answer: 
By product rule we have $\frac d {dx} (x^{2}y)=x^{2}-1$ so $x^{2}y=x^{3}/3-x+C$. Divide by $x^{2}$.
From :
$$x^2\left(\frac{dy}{dx}\right)+2xy=x^2-1$$
$$\left(\frac{dy}{dx}\right)+\frac{2}{x}y=1-\frac{1}{x^2}$$

Given that :
$$p(x)=\frac{2}{x}$$

Find the Integrating Factor, $m(x)$ :
$$m(x)=e^{\int p\left(x\right)dx}$$
$$m(x)=e^{\int \frac{2}{x}dx}$$
$$m(x)=e^{2\ln \left(x\right)}$$
$$m(x)=e^{\ln \left(x\right)^2}$$
$$m(x)=x^2$$

Multiply both sides with Integrating Factor :
$$x^2\left(\frac{dy}{dx}+\frac{2}{x}y\right)=x^2\left(1-\frac{1}{x^2}\right)$$
$$x^2\frac{dy}{dx}+2xy=x^2-1$$

Let :
$$2x=\frac{d}{dx}\left(x^2\right)$$

Substitute into equation :
$$x^2\frac{dy}{dx}+\frac{d}{dx}\left(x^2\right)y=x^2-1$$

Apply the reverse product rule :
$$\frac{d}{dx}\left(x^2y\right)=x^2-1$$

Integrate both sides with respect to $x$ :
$$\int \frac{d}{dx}\left(x^2y\right)dx=\int \left(x^2-1\right)dx$$

Evaluate the integrals :
$$x^2y=\frac{x^3}{3}-x+C$$
$$y=\frac{x}{3}-\frac{1}{x}+\frac{C}{x^2}$$

Final answer :
$$y(x)=\frac{x}{3}-\frac{1}{x}+\frac{C}{x^2}$$