Change your circuit to look like this:
simulate this circuit – Schematic created using CircuitLab
In your circuit you connect base to +9V and emitter to 0V, that is not good and may kill the transistor. A BJT (bipolar junction transistor) as drawn is current driven: you need a small base current to make it conduct a large current from collector to emitter. The base-to-emitter voltage should never be higher than 0.6~0.7V or so and that is where my R2 comes in.
So base voltage is given: approximately 0.7V. The base current can be calculated as follows:
\$I_B = \dfrac{U_{R2}}{R2}= \dfrac{9\text{V}-0.7\text{V}}{10\text{k}\Omega}\approx0.8\text{mA}\$
The collector current is limited by R1 and D1 if the transistor is saturated. Saturated means there is almost no voltage across collector and emitter.
\$I_C= \dfrac{V1-V_{D1}}{R1} = \dfrac{9-1.8\text{V}}{470\Omega}\approx 15\text{mA}\$
So the current minimum current gain you want from your transistor is:
\$h_{FE} = \dfrac{I_C}{I_B}=\dfrac{15\text{mA}}{0.8\text{mA}} \approx 20\$
If you look at the datasheet for your 2N2222datasheet for your 2N2222 and look up the hFE-parameter you'll find it is much larger than 20 (minimum 75 according to the datasheet) therefore the transistor will suffice. You can even consider increasing R2 to about 47kΩ33kΩ and it should still work just fine.