This Bible contradiction is from the Skeptic's Annotated Bible.
David never sinned. (He was clean and righteous.)
2 Samuel:22:21 View context
The LORD rewarded me according to my righteousness: according to the cleanness of my hands hath he recompensed me.
2 Samuel 22:25 View context
Therefore the LORD hath recompensed me according to my righteousness; according to my cleanness in his eye sight.
1 Kings 3:14 View context
And if thou wilt walk in my ways, to keep my statutes and my commandments, as thy father David did walk, then I will lengthen thy days.
1 Kings 9:4 View context
And if thou wilt walk before me, as David thy father walked, in integrity of heart, and in uprightness, to do according to all that I have commanded thee, [and] wilt keep my statutes and my judgments:
1 Kings 14:8 View context
And rent the kingdom away from the house of David, and gave it thee: and [yet] thou hast not been as my servant David, who kept my commandments, and who followed me with all his heart, to do [that] only [which was] right in mine eyes;
David never sinned, except in the matter of Uriah.
1 Kings 15:5 View context
Because David did [that which was] right in the eyes of the LORD, and turned not aside from any [thing] that he commanded him all the days of his life, save only in the matter of Uriah the Hittite.
David sinned in numbering the people.
2 Samuel 24:10 View context
And David's heart smote him after that he had numbered the people. And David said unto the LORD, I have sinned greatly in that I have done: and now, I beseech thee, O LORD, take away the iniquity of thy servant; for I have done very foolishly.