More efficient to do SELECT and compare in Java or DELETE and INSERT
Neither of your proposals can be considered efficient. MERGE was introduced a long time ago (SQL99 or SQL2003) and will outperform both of your alternatives:

MERGE INTO T as x
USING (
    VALUES (?, ...., ?)
) as y (c1, c2, ...,cn)
    ON x.&lt;key&gt; = y.&lt;key&gt;
WHEN MATCHED AND (x.c1, x.c2, x....) &lt;&gt; (y.c1,y.c2, y...) THEN 
    UPDATE (...)
    VALUES (y..)
WHEN NOT MATCHED THEN
    INSERT (...)
    VALUES (...)