Fix database reconnection

Fixes bug 1103904

Change-Id: I2f3bc450d5d7ea04c20b3be2afed3c0c5a00435a
Merge "Fix database reconnection"