Automatically reconnect on database disconnection.

The supplied code will automatically handle reconnecting to MySQL servers upon a disconnection received. I highly recommend merging this fix.