title: MySQL batch stmt with Statement.RETURN_GENERATED_KEYS
body: <p>I am trying to execute 2 sql statements in a batch.  the first statement is an insert that uses a auto generated value for its ID.  the second statement is an insert to another table but it needs to use the auto generated value from above as part of the insert value</p>
  
  <p>something like (where id is just to show the auto generated field its not defined in sql</p>
  
  <pre><code>stmt.addbatch(insert into table1("id_auto_generated", "foo"));
  stmt.addbatch(insert into table2("table1_id", "boo"));
  </code></pre>
  
  <p>the way I do it now is by using this in my second sql</p>
  
  <pre><code>insert into table2(LAST_INSERT_ID(), "boo");
  </code></pre>
  
  <p>Problem is its slow even in batch statements its very slow as my batch can be 50,000 inserts.</p>
  
  <p>I wanted to switch to prepared statements but do not know how to use Statement.RETURN_GENERATED_KEYS  or LAST_INSERT_ID()  with prepared statements.</p>