"Wash me, cleanse me, purge me, create me a clean heart, renew my spirit, restore joy to me, deliver me."
The imperative verbs fly fast and furiously in this Psalm of repentance. David knows he has deeply offended God with Bathsheba (vs 4). But he also knows he can't let that offense keep him at a distance from God. He needs to come and ask God to do MORE things for him. This is hard, but necessary. When we sin against someone, our natural reaction is to avoid them, and hope time makes it fade away.
Better to go to God first. Whoever else you have hurt, you've offended God by failing to love your neighbor, made in His image. Think of what you did. Agree with God that it was wrong and is against His will. Ask Him not just for forgiveness (David never uses that word), but for cleansing, purging away of the sin (vss 2, 7), and renewal in righteousness (vs 10).
David repented well to God, we see in Psalm 51. Interestingly, it is less clear that David repents well to others. He may have, but it isn't in the story (2 Samuel 12 ff.). Instead, we see things get worse with Joab, Amnon and Tamar, and Absalom.
Major sins multiply troubles, even if the sin doesn't directly cause the trouble.
David's life shows us that God usually mixes mercy with discipline, in response to our sin. Bathsheba's first child dies in judgment. But Solomon is born. His name is simplistically translated peace, but "shalom" has a deeper meaning of being made complete or whole.
May God grant you the mercy of repentance when you sin, of having both the guilt and the presence of the sin purged from you, and the mercy of restored relationships where that is possible.