Added exception when database is not connected