Since you are using a PreparedStatement below, it would make sense to move this loop to migrateUnitsToCodedValue() method so that you prepare and close the PreparedStatement object once, it also means you can do the update once by turning off auto commit and commit/rollback everything in one go.