title: Java Oracle Transaction
body: <p>I want to insert data into a database into different tables. Because of constraints I have to do this in a specific order. That means, first insert into table a, then b, then c , .... and no mixing of the tables.
  But I'm writing a program, which get multiple csv files and should import them into the database, but the program can't know what is the right order. So I thought transaction would be the right way, because I heard, that the data consistency must only exists at the end of the transaction. But that doesn't works</p>
  
  <p>My code looks like that:</p>
  
  <pre><code>Connection connection = DriverManager.getConnection(url, user, pw);
  connection.setAutoCommit(false);
  Statement statement = connection.createStatement();
  statement.addBatch("INSERT INTO c ....");
  statement.addBatch("INSERT INTO a ....");
  statement.addBatch("INSERT INTO b ....");
  statement.addBatch("INSERT INTO a ....");
  // ...
  statement.executeBatch();
  statement.close();
  connection.commit();
  </code></pre>
  
  <p>But I will get ORA-02291 (integrity constraint violation) :-(</p>