Adding basic code to attempt to recreate the connection if the db driver says it's been closed by the driver - bug 556

Cleaning up db reconnect code so it's centralized, will work from most systems that could strongly require a db reconnect