because David did what was right in the eyes of the LORD, and had not turned aside from anything that He commanded him all the days of his life, except in the matter of Uriah the Hittite.
1 Kings 15:5
Surrounding context
15:4 Nevertheless for David's sake the LORD his God gave him a lamp in Jerusalem, by setting up his son after him and by establishing Jerusalem;
15:5 because David did what was right in the eyes of the LORD, and had not turned aside from anything that He commanded him all the days of his life, except in the matter of Uriah the Hittite.
15:6 And there was war between Rehoboam and Jeroboam all the days of his life.