How do I avoid the following error message is shown to normal users?
PDOException: SQLSTATE[HY000] [1040] Too many connections in lock_may_be_available()
There are two issues here:
For 1, go to admin/config/development/logging
and set Error messages to display to None. Don't worry, this won't affect messages like "incorrect login details" or "page not found, we did a search instead" ... things that the user really needs to know.
As for 2, here are a couple of things to try: