prepared statements in MySQL

Is there any advantage to using prepared statements in Java for DML in the following

get a connection, prepare a statement, substitute the variable value, execute, close the
statement - repeat this process over and over.

Don’t you need to not close so that you don’t have to re-prepare the statement
in order to gain any performance advantage?

That is correct, you need to hold the handle for the prepared statement and re-execute it with just different values each time.

prepare statementLOOP: execute statement with different valuesEND:close statement.