He was confident that God will always do what He says He will do. It is unreasonable to expect people to meet our needs. David's outburst of praise and confidence in God is motivated by the stark reality that all people will eventually disappoint us. In some way they will not meet our expectations. After we got married Sonia discovered that I did not meet all of her expectations of a husband.
Marriage never matches our expectations.
Many times King David must have thanked God for son number three. We know that David had high expectations from the very name he gave Absalom which has the root meaning of Father of peace. It also has the idea of friendly. From the top of his head to the sole of his foot there was no blemish in him. But this charismatic son who was expected to be the father of peace declared war on his father.