Possible solution to no connection to database after some time