$\int u.v=u.v_{1}-u^1.v_{2}+u^2.v_{3}+.....$
where u and v are your original functions
$u^1=first\,derivative\,of\,u$
$v_1=first\,integral\,of\,v$
$u^1=2x,u^2=2$ $\, v_1=sinx,v_2=-cosx,v_3=-sinx$
it is clear that after term $u^2$ everything in integral would be 0.
so plugging in values we get
$\int x^2 cosx dx=[x^2sinx+2xcosx-2sinx]$
now find $[x^2sinx+2xcosx-2sinx]_0^{\pi}=-2\pi$