Make db connection thread safe.
Allow queue to be null.