In the event that this problem should occur again, cf. this thread. 😉
Caffeine is a stimulant, and it's very difficult to sleep if you've had enough of it.
However, I offer you a suggestion for study skills: cramming or pulling an all-nighter are actually bad study habits, as you absorb much less information and process it slower when tired. A better idea is to read it over a few times then go to bed, for the reasons of:
A) You won't be as tired, and your mind will absorb more information
B) The time that your brain takes to process the information will happen while you are sleeping
So it's in your best interest not to go all night if you have an exam.
No idea how you'd get to sleep now though...