title: Oracle Update Batching Models - Using both batching models in same application
body: <p>Oracle JDBC supports two distinct models for update batching: Standard Batching and Oracle Specific Batching. </p>
  
  <p>According to oracle 11g JDBC Developer Guide, in any single application, you can use one model or the other, <strong>but not both. Oracle JDBC driver will throw exceptions when you mix these</strong>.</p>
  
  <p>In my standalone application, the above statement does not hold true. I want to know if I am missing something.</p>
  
  <p>In my application I create a OracleDataSource and do the following</p>
  
  <p><pre><code>
      connection = datasource.getConnection();
      preparedStatement = connection.prepareStatement("update CAR set CAR_NAME=?, OBJECT_VERSION=? where CAR_ID=?");
      for(Car car : cars) {
         preparedStatement.setString(1, car.getName());
         preparedStatement.setInt(2, car.getVersion() + 1);
         preparedStatement.setLong(3, car.getId());
         preparedStatement.addBatch();
      }</p>
  
  <code>System.out.println("Update Batch : " + Arrays.toString(preparedStatement.executeBatch()));
  
  
   for(Car car : cars) {
       car.setName("v car " + car.getId());
   }
  
  
  //Oracle Update Batching 
  
  connection.setAutoCommit(false);
  
  PreparedStatement preparedStatement =
            connection.prepareStatement("update CAR set CAR_NAME=?, OBJECT_VERSION=? where CAR_ID=?");
  
  //Change batch size for this statement to 3
  ((OraclePreparedStatement)preparedStatement).setExecuteBatch (10);
  
     for(Car car : cars) {
        preparedStatement.setString(1, car.getName());
        preparedStatement.setInt(2, car.getVersion() + 1);
        preparedStatement.setLong(3, car.getId());
        System.out.println("Execute Update Count " + preparedStatement.executeUpdate());
     }
  
     System.out.println("Update Count : " + ((OraclePreparedStatement)preparedStatement).sendBatch()); // JDBC sends the queued request
  
     connection.commit();
  
     preparedStatement.close();
  </code></pre>
  
  <p></code></p>
  
  <p>The above code runs well and I could see both the update batches using different batching models getting executed well. Is there anything which I missed out or my interpretation of jdbc developer guide is incorrect?</p>
  
  <p>Thanks in advance</p>