BatchUpdates + Forein Keys

I am trying to create a preparedstatement that uses a for loo to insert multiple records at once. The isert works with no problems, however when I try to save data to a supporting table i get Foreign key constaint errors. I am assuming that the problem is in that the insert has not yet finished, so teh Primary keys in the first table cause a FK error. Is there a way around this? I have autocommit set to true and if I set it to false, and place a commit after the executeUpdate it returns the same results.

My code is as follows:

PreparedStatement insertEvents = con.prepareStatement("INSERT INTO Event (event_id, event_uuid, summary) VALUES (?,?,?)";

for (Event event : eventList) {

insertEvent.setInt(1, event.getPrimaryKey());

insertEvent.setString(2, event.getUUID);

insertEvent.setString(3, event.getSummary);

}

insertEvents.executeUpdate();

// I then try to save to the supporting tables and the error is thrown on the first record.

[1002 byte] By [Mike_Calgooa] at [2007-11-27 6:10:48]
# 1
If you are only inserting into a single table then a foreign key constraint has nothing to do with batching.If you are doing more than one table then you need to sequence the batch so it does the inserts in the correct order.
jschella at 2007-7-12 17:16:34 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...