When you apply indefinite integration, you need to add a "${}+C\,$" (or whatever letter you want) at the end; this is rather infamous for tripping up students. In your problem this gives
$-\frac{1}{y}=\frac{x^2}{2}+C~~\implies~~ y=\frac{1}{-(x^2/2+C)}=\frac{2}{-x^2-2C}.$
If we write $K=-2C$ (or again, any old letter), we can write this simply as $\displaystyle\frac{2}{K-x^2}$.
The reason we have "plus a constant" at the end is to prevent erroneous derivations like this:
$\frac{d}{dx}f(x)=\frac{d}{dx}\big(f(x)+1\big)\implies f(x)=f(x)+1\implies 0=1.$
In other words, antidifferentiation will only find the antiderivative you want up to addition by an unknown constant. (However with some initial conditions this constant, or constants as it may be in more complicated problems, may be computed exactly.)
Note that it is only necessary to write an add-a-constant to one side of an equation, because for example something like $f(x)+A=g(x)+B$ can be written instead as $f(x)=g(x)+C$ with our constant $C=B-A$.