title: How do I batch sql statements with package database/sql
body: <p>How do I batch sql statements with Go's database/sql package?</p>
  
  <p>In Java I would do it like this :</p>
  
  <pre><code>// Create a prepared statement
  String sql = "INSERT INTO my_table VALUES(?)";
  PreparedStatement pstmt = connection.prepareStatement(sql);
  
  // Insert 10 rows of data
  for (int i=0; i&lt;10; i++) {
      pstmt.setString(1, ""+i);
      pstmt.addBatch();
  }
  
  // Execute the batch
  int [] updateCounts = pstmt.executeBatch();
  </code></pre>
  
  <p>How would I achieve the same in Go?</p>