Hello,
I have created a transaction consisting of several batch updates in
order to improve the performance(i.e. executeBatch() commands).I 'd expect (according to jdbc) when an executeBatch()
commmandthrows
an exception the transaction rolls back, that is updates the previous
executeBatch() commands containing in the transaction have incurred are
ignored.
However I think in postgresql a batch update is considered to be a
transaction. This is incompatible with jdbc.
Here is a part of the codecon.setAutoCommit(false);stmt.addBatch("CREATE TABLE t1 (id int)");stmt.addBatch("CREATE
TABLE t2 (id int)");stmt.addBatch("CREATE TABLE t3 (test int)");int [] updateCounts = stmt.executeBatch();
stmt.clearBatch();stmt.addBatch("CREATE TABLE t4 (id int)");stmt.addBatch( "CREATE TABLE t4 (id int)"); int []
updateCounts1= stmt.executeBatch();con.commit(); } catch(SQLException ex) con.rollback();
System.err.println("SQLException:" + ex.getMessage(
));
}
}