Fix for null connection issue on login failure in queryRaw

When a login fails fails in queryRaw, the connection passed into the onOpen callback will be null. We need to guard against this.