I am trying to use JDBC to insert into multiple tables. Because it has to be fast I want to use PreparedStatement
and the executeBatch
method. Tables are combinded by a foreign key relationship.
First idea was to use
getGeneratedKeys()
but this fails with some JDBC drivers. E.g. PostgreSQL.Second idea was to use the SQL-currval(...)-function. But having to call execute batch for one statement and the for the other makes all keys the same value. So this method also fails.
JDBC doesn't accept semicolon separeted inserts.
How can I achieve this?