Added autoreconnection for database