Added exception handling to database creation and deletion