added checks for DB disconnect

Signed-off-by: Bart Piwowar <bart.piwowar@gmail.com>