Error catching

Added try and catch blocks around important database connection methods