This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
Most databases disable automatic opening transactions by the default so that whenever you open a connection and submit an update, delete or insert statement, they are automatically committed.
However, most of these databases also offer string connection options where you can overwrite this default behavior and tell to database to automatically open a new transaction either whenever a new connection is opened or even right after you explicitly commit an opened transaction.
In MySQL for example, you can force a connection to be "commit aware" in two ways :
Through connection string : Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/test?user=monty&password=great&elideSetAutoCommits=true");
conn.setAutoCommit(false); // Default value is true;
Hope that helps. [ June 03, 2007: Message edited by: Edisandro Bessa ]
"If someone asks you to do something you don't know how to, don't tell I don't know, tell I can learn instead." - Myself
Joined: Feb 26, 2005
I am wondering, when the jdbc update is neither inside programmatic UserTransaction transaction, nor in an ejb method which is on container-transaction 'Required'....
In short, inside ejb business method, a method which is not running in transaction, e.g. 'NotSupported', not even propagated transaction, ... if a jdbc update is basically committed instantly (not considering lazy update by db server).
I guess the answer is yes, it is automatically committed, if transaction is not involved at all; just like in a standalone client doing jdbc updates.