Soon I'll have my first guitar so I would like to know what kind of exercises should be done just before playing to prevent hand problems, like... stretch my hands and stuff like that?

Just do some arm stretches like you're about to play a sport. Pull your arm across your body to stretch you shoulders. Push your arm down behind your head. Stretch and massage each finger individually. Even rotate you head around to loosen your neck up.

Doing these things will help keep your body loose and relaxed. It'll prevent cramps and let you play longer without locking up.
here's a basic warm up:
E -2-3-4-5
B -2-3-4-5
G -2-3-4-5
D -2-3-4-5
A -2-3-4-5
E -2-3-4-5 do this going from low E to high E & back a couple times, also pentatonic scales are good.
well if you're talking about playing I recommend this as well:

For picking hand:
Repeat going up AND down

For fretting hand:

and so on
Im surprised no one has had a masturbation joke yet...
My Rig:
Epiphone Les Paul Custom - Alpine White
Vox AD30VT
Epiphone SG Special - Black
Planet Waves Cables
Levy's Strap
Dunlop .70 Picks
Stretch your hands, watch the John Petrucci Rock Discipline video, find it on google video.
"Play with your ears" - Yngwie Malmsteen, Paul Gilbert
Thats what she said...

That's the actual thing for PROPER warming up before playing, from Mr Petrucci.

Jackson DKMG & KE3, Fender Mexican Strat, Stagg Acoustic

Boss Compressor & Chorus, Dunlop Crybaby, Behringer Delay, ISP Decimator, Ibanez Tubescreamer

Laney TT50H, Marshall 1960A, Roland Cube 15

Looking to jam in Belfast, PM me!