Reconnect to the SQL database when the connection times out

The `isValid(int timeout_seconds)` method will handle the cases where the connection has timed out due to inactivity. When the connection is no longer valid, we trigger the connection recreation code.