The converse of Whitehead's first and second lemma has been recently studied by P. Zusmanovich, e.g., see [here](http://arxiv.org/abs/0704.3864). One of the results is as follows:

*Theorem 0.2* (A converse to the Second Whitehead Lemma). A finite-dimensional Lie algebra over a field of characteristic zero such that its second cohomology with coefficients in any finite-dimensional module vanishes, is one of the following:<br>

(i) an one-dimensional algebra; <br>
(ii) a semisimple algebra; <br>
(iii) the direct sum of a semisimple algebra and an one-dimensional algebra.

If you only require that $H^2$ vanishes for the trivial representation, we have much less, of course.