Joseph was pursued by a married woman; David pursued a married woman.
Joseph was tempted by a beautiful woman; David was tempted by a beautiful woman.
Joseph was a mere slave; David was a king with a public life to uphold
Joseph probably didn’t have too many women to choose from; David could have any woman he wanted