The church isn’t in the O.T. (Eph); and the context of Solomon’s verse is experiential observation— not stating doctrine.
Hermaneutics.
Did you ever hear of or study typology?
Ot’s applying the Old Testament to the New Testament.
There IS such a thing as JUST war.