When David faced Goliath, he was not trained as a warrior, or even as a soldier. He was simply skilled at keeping sheep safe. He had been prepared for the encounter with Goliath, though. He recognized when he stood before Goliath the two courses he had been enrolled in that made him ready: one day, he had been empowered by Yahweh to kill a lion, and on another, to kill a bear. This day, it would be Goliath!
He did not seem to have the same strength for dealing with the power of Bathsheba’s beauty. Since the revelation of his errors regarding his relationship with her came to him through the prophet Nathan’s story about a sheep, I expect that Yahweh had given him the instruction that should have been preparation, but he didn’t apply the lesson to the temptation. Nathan’s story prompted David to see the sin in the parable, but not in his life. David responded by condemning the behavior of the sheep thief. Nathan then pointed out that David was the thief. Suddenly it all became clear to him and he repented of his sin (2 Samuel 12:1-15).
Difficult situations that seem to promise our destruction or loss are frequently (usually?) courses of instruction in which we learn the ways or power of Yahweh. They are frequently (usually?) not even really about the potential loss at hand, but a future victory that we could be using them to prepare for.
Expect every difficulty to be a promise of some future challenge that is much greater, with a prize behind it that is also much greater. Be awesome.