According to the Mosaic Law, both David and Bath - sheba should have been put to death.
لِذلِكَ غَفَرَ لَهُ يَهْوَه خَطِيَّتَهُ وَمَارَسَ ضَبْطَ ٱلنَّفْسِ عِنْدَ إِنْزَالِ ٱلْعِقَابِ بِهِ وَبِبَثْشَبَعَ .‏