The same David one who took the wife of someone else and had her husband sent to be killed in battle?
Yep. That's the one. He was human and a sinner like everyone else in the bible except for Jesus. And God forgave him and continued to enforce the covenant he made with him. He continued to call him "a man after may own heart" and kept someone from his line on the throne of Judea and also kept his promise that the Messiah would come from his line and rule on his throne forever. That David.
I would also note that God (and therefore Jesus) counseled David on when to go to battle and, on occasion, how to conduct those battles. Further the most battle experienced man that Jesus ever met in the Gospels, the Roman Centurian, was commended by Jesus to have more faith than anyone else in Israel.