Implemented persistent database connections.
Added check for out-of-date connections at request start.

Thanks Karen Tracey for pointing out possible problems with MySQL.
Check if connections that encountered errors still work.

Thanks Anssi Kääriäinen for the suggestion.