Why did David take Bat Shevah without consulting the Lord. We know in Kabbalah that she was very special, her name means, Daughter of oath, and David in a vision knew that she was special, and from her came Shlomo who was the ancestor of Meshiach. And the second question is, was Uriyah a righteous man or not.
King David had sinned with Uriya and Bat Sheva. The different commentators dispute what exactly his sin was, yet our sages (Shabbat 56a) teach us it wasn’t simple adultery like one might misinterpret from the text. It might be, that a part of his sin was that he didn't speak to a prophet of a Halachic authority. As for Uriya, there are different opinions whether he was Jewish, a convert or a righteous non-Jew (Ger Toshav) (see Tzitz Eliezer 21 26). According to our sages (ibid) he has sinned to King David by disrespecting him as king by referring to his commander as master rather than the king's servant and consequently deserved the death penalty.