connection.setAutoCommit(false) in batch updates
843859Mar 13 2008 — edited Mar 14 2008Hy, I have somes doubts with batch updates. Here they goe. I have the next code:
Class.forName("com.mysql.jdbc.Driver");
Connection connection=DriverManager.getConnection("jdbc:mysql://localhost/clients", "root", "");
connection.setAutoCommit(false);
Statement sentence=connection.createStatement();
sentence.addBatch("INSERT INTO dataclients dni VALUES('45464564' );
sentence.addBatch("INSERT INTO dataclients dni VALUES('456456');
sentence.executeBatch();
1.This line " connection.setAutoCommit(false)" means that all the sentences sent by the executeBatch() will not be permanent and so then I will have to call "connection.commit" after "sentence.executeBatch()" to make them permanent?
2.What happens if I dont use "connection.setAutoCommit(false)"? The batch is not executed like a batch? The sentences of the batch are sent one by and not in group?
Thanks