Try the ansatz $y(x) = p(x)e^x$, where p(x) is a polynomial. Then,
$$ y'(x) = p'(x)e^x + p(x)e^x $$
$$ y''(x) = p''(x)e^x + 2p'(x)e^x +p(x)e^x$$
Inserting all this into your equation, the $e^x$'s cancel and
$$(x+3)(p''(x)+ 2p'(x) +p(x)) - (2x+7)(p'(x) + p(x)) + 2p(x) = (x+3)^2$$
The right hand side has degree 2. The largest degree on the left comes from $xp(x)$. Therefore p(x) must be linear. Letting $p(x) = mx +b$, then $p'(x)= m$ and $p''(x) = 0$. Thus we get,
$(x+3)(2m +mx +b) - (2x +7)(m + mx + b) +2(mx+b) = (x+3)^2 = x^2 +6x + 9 $
This leads to
$ -m x^2 - (2m + b)x - (2b+m) = (x+3)^2 = x^2 +6x + 9 $
which gives us $m=-1, b = -4$. Therefore, we have the particular solution
$y_p(x) = -(x+4)e^x$.
To find the general solution we must solve the homogeneous equation:
$(x+3)y''(x) - 2(x+7)y'(x) + 2y(x) = 0$
Since a linear solution worked last time let's try it again, $y(x) = nx + c$.
$ 0 -(2x+7)n + 2(nx+c) = 0$
$ -7n + 2c = 0$
It should be expected that we have one degree of freedom remaining since, unlike the last case, in the homogeneous case a multiple of a solution is a solution. Therefore, we have $y(x) = nx +c = c(\frac{2}{7}x + 1)$.
Since the only other function we have to work with here is the exponential, let's try $y(x) = e^{\lambda x}$. Plugging this in the homogeneous equation,
$ (x+3)\lambda^2 - (2x+7)\lambda +2 = 0$
$ (\lambda^2- 2\lambda) x + 3\lambda^2 -7\lambda + 2 = 0 $
which can only hold for all x if $\lambda = 2$. Therefore, the general homogeneous solution is,
$y_h (x) = de^{2x} + c(\frac{2}{7}x + 1)$
where c and d are constants (the two homogeneous solutions are clearly linearly independent). The general solution is then,
$y(x) = y_p(x) + y_h(x) = -(x+4)e^x + de^{2x} + c(\frac{2}{7}x + 1)$