Construct an sql
statement with both the queries (INSERT and UPDATE) using PreparedStatement
and executes executeBatch
which is according to the documentation Submits a batch of commands to the database for execution and if all commands execute successfully, returns an array of update counts
like
preparedStatement.executeBatch();