When I have a cavity filled all I can say is praise to the Novocaine. When my dad was little, his dentist didn't use local anesthetics, and my poor dad had to sit in the chair knowing he was in for a whole lot of pain. My jaw hurts just thinking about it.
I just learned that prior to the invention of Novocaine, cocaine was used as a local anesthetic. Cocaine constricts blood cells, which reduces bleeding, but as we all know it's also highly addictive.
In the early 1900's scientists created a synthetic version of cocaine, but without the nasty side effects, and christened it Procaine. We know it by its trade name Novocaine, and I have no idea why my dad's dentist didn't use it since it was definitely available to the masses when he was a boy. Since its development, stronger local anesthetics have come along like Lidocaine, Septacaine, and Mepivocaine (most dentists still call the shot "Novocaine" though, so ask what they specifically use if you're interested).
These injectable local anesthetics prevent pain in a specific area by blocking the nerves that sense or transmit pain, so the area feels numb for up to 3-4 hours.
All I can say is that even though the shot stinks and can really pinch your gum (and make your mouth really sore for days after), it's still way better than how much it would hurt with NO shot at all.
Fit's Tip: Ask your dentist to apply a topical anesthesia to your gums to numb the area before the Novocaine shot. It makes getting a cavity filled just a little bit easier to bare.