Added openmp critical #pragmas, as the mysql library is not thread safe
Allowed for a reconnection to the DB if the connection drops