title: How to use a foreach-loop in Scala that mutates an object?
body: <p>I use Scala and JDBC, now I want to reuse an <code>PreparedStatement</code> to do a multi-insert. I want to use a foreach-loop over an array, but I can't get it right with Scala.</p>
  
  <pre><code>val stmt = conn.prepareStatement(insertStatement)
  
  // wrong Scala
  items.foreach(item : MyItem =&gt;
      stmt.setInt(1, item.id)
      stmt.setInt(2, item.value)
      stmt.executeUpdate()
      )
  </code></pre>
  
  <p><code>items</code> is an array containing multiple <code>MyItem</code>.</p>
  
  <p>How can I write this foreach-loop in Scala and reuse the <code>PreparedStatement</code>?</p>