Add error handling for database connection