I'm working with JDBC to connect to Oracle. I tested connection.setAutoCommit(false)
vs connection.setAutoCommit(true)
and the results were as expected.
While by default connection is supposed to work as if autoCommit(true)
[correct me if I'm wrong], but none of the records are being inserted till connection.commit()
was called. Any advice regarding default behaviour?
String insert = "INSERT INTO MONITOR (number, name,value) VALUES (?,?,?)";
conn = connection; //connection details avoided
preparedStmtInsert = conn.prepareStatement(insert);
preparedStmtInsert.execute();
conn.commit();
From Oracle JDBC documentation:
The other thing is - you ommitted connection creation details, so I'm just guessing - if you are using some frameworks, or acquiring a connection from a datasource or connection pool, the
autocommit
may be turnedoff
by those frameworks/pools/datasources - the solution is to never trust in default settings ;-)