Exam stress is the only things that brings mine on - I think it's something to do with the tiny veins in your head narrowing with tension. Relaxing is probably the answer to it.
migraine is more to do with a chemical release, thats all i know on that. if your stressed, the muscles around your jaw and kneck get tight, the kneck muscles are joined to a sheath which covers part of yr skull, when they get stressed they tighten up which pulls on this sheath type matter,and will give you a headache.