Added support for reconnecting in case that db connection is broken