title: using JDBC preparedStatement in a batch
body: <p>Im using <code>Statement</code>s batchs to query my data base. 
  Iv'e done some research now and i want to rewrite my application to use <code>preparedStatement</code> instead but i'm having hard time to figure out how to add queries to a <code>preparedStatement</code> batch.</p>
  
  <p>This is what i'm doing now:</p>
  
  <pre><code>private void addToBatch(String sql) throws SQLException{
  sttmnt.addBatch(sql);
  batchSize++;
  if (batchSize == elementsPerExecute){
      executeBatches();
  }
  }
  </code></pre>
  
  <p>where <code>sttmnt</code> is a class member of type <code>Statement</code>.</p>
  
  <p>What i want to do is to use the <code>preparedStatement</code>'s <code>setString(int, String)</code> method to set some dynamic data and then add it to the batch.</p>
  
  <p>Unfortunately, i don't fully understand how it works, and how i can use <code>setString(int, String)</code> to a specific sql in the batch OR create a new <code>preparedStatemnt</code> for every sql i have and then join them all to one batch.</p>
  
  <p>is it possible to do that? or am i really missing something in my understanding of <code>preparedStatement</code>?</p>