title: Inserting multiple rows using JdbcTemplate
body: <p>How can I execute the following SQL in a scalable way using <a href="http://static.springsource.org/spring/docs/3.0.2.RELEASE/javadoc-api/org/springframework/jdbc/core/JdbcTemplate.html" rel="noreferrer">JdbcTemplate</a> running on mySQL. In this case, scalable means:</p>
  
  <ol>
  <li>Only one SQL statement is executed on the server</li>
  <li>it works for any number of rows.</li>
  </ol>
  
  <p>Here's the statement:</p>
  
  <pre><code>INSERT INTO myTable (foo, bar) VALUES ("asdf", "asdf"), ("qwer", "qwer")
  </code></pre>
  
  <p>Assume that I have a list of POJO's with <code>foo</code> and <code>bar</code> fields. I realize that I could just iterate over the list and execute:</p>
  
  <pre><code>jdbcTemplate.update("INSERT INTO myTable(foo, bar) VALUES (?, ?)", paramMap)
  </code></pre>
  
  <p>but that doesn't doesn't accomplish the first criterion.</p>
  
  <p>I believe I could also execute:</p>
  
  <pre><code>jdbcTemplate.batchUpdate("INSERT INTO myTable(foo, bar) VALUES (?, ?)", paramMapArray)
  </code></pre>
  
  <p>but from what I can tell, that will just compile the SQL once and execute it multiple times, failing the first criterion again.</p>
  
  <p>The final possibility, which seems to pass both criteria, would be to simply build the SQL myself with a <code>StringBuffer</code>, but I'd like to avoid that.</p>