title: JDBC insert multiple rows
body: <p>I am now using batch:</p>
  
  <pre><code>String query = "INSERT INTO table (id, name, value) VALUES (?, ?, ?)";
  PreparedStatement ps = connection.prepareStatement(query);            
  for (Record record : records) {
      ps.setInt(1, record.id);
      ps.setString(2, record.name);
      ps.setInt(3, record.value);
      ps.addBatch();
  }
  ps.executeBatch();
  </code></pre>
  
  <p>I am just wondering if the above code is equivalent to the following code. If not, which is faster?</p>
  
  <pre><code>String query = "INSERT INTO table (id, name, value) VALUES ";
  for (Record record : records) {
      query += "(" + record.id + ",'" + record.name + "'," + record.value + "),";
  }
  query = query.substring(1, query.length() - 1);
  PreparedStatement ps = connection.prepareStatement(query);
  ps.executeUpdate();
  </code></pre>