When the Israelites were about to enter the promised land, Joshua told them that God was certainly going to drive out the nations that were already living there, including the Jebusites.
But later in the book of Joshua, it says the tribe of Judah failed to make the Jebusites leave Jerusalem. Instead, they have had to live alongside them “to this day”. Later, the book of Judges says the Benjamites weren’t able to drive out the Jebusites either. And again, it says they still live there together “to this day”.
David managed to capture the fortress of the Jebusites, but that doesn’t mean he got rid of the Jebusites. During his son’s reign, there were still Jebusites left in the land, because the Israelites had been unable to exterminate them.
And even in the time of Ezra, when the kingdoms of Israel and Judah didn’t even exist anymore, most of those nations Joshua had said would be driven out, including the Jebusites, were still around and living there with the Jews. They never did get driven out.