commit « Transaction « Java Database Q&A





1. can not set auto commit in user transaction    coderanch.com

I created an entity bean in which I have an update method. This method updates three tables, so I have to do the followings: try{ con=getConnection(); con.setAutoCommit(false); //do transaction con.commit(); } catch(Exception e){ } finally{ //error comes up when execute the following line con.setAutoCommit(true); // con.close(); } I get this error message while running in weblogic server : could not set ...

2. autocommit - turning on after transaction is committed?    coderanch.com

When I turn off autocommit to perform transactions (such as two stored procedure calls involving inserts), is it necessary that I set autocommit(true) after committing? Example code (using Sun's example, which is close to mine): con.setAutoCommit(false); PreparedStatement updateSales = con.prepareStatement( "UPDATE COFFEES SET SALES = ? WHERE COF_NAME LIKE ?"); updateSales.setInt(1, 50); updateSales.setString(2, "Colombian"); updateSales.executeUpdate(); PreparedStatement updateTotal = con.prepareStatement( "UPDATE COFFEES ...

3. transaction size and commit    coderanch.com

Hi: I need to perform a commit after N records have been inserted. After each insert, I increase a counter, then call commit() if N records are inserted. Is this the most efficient way, or does JDBC have an "internal" way of knowing that N records have been inserted, then "automatically" committing them? Right now, I have this: rptDataConn = dbConnection(dataSourceName); ...

4. does commit return before transaction complete    coderanch.com

Hello All, I have a ques.. can you tell me whats going on here: I request an update and then try to read the updated data.. but I do not see the changes in my jsp (I do see the changes in database).. then I do a refresh on my jsp again which calls getDetails() method and this time I do ...

5. Queries not committing in transaction    coderanch.com

I have this JDBC code where I need to insert a record and then get the id of that inserted column. Everything works fine until I run a threaded test that tries to do 10 of these at once. The problem is that everything seems to run OK. The log prints out the id. But when I query the database only ...

6. jdbc update committed instantly when outside of transaction?    coderanch.com

Jesus, The answer for your question is : It depends ... 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 ...

7. Second thread is blocked until the first thread commit the transaction, I can not understand why...    coderanch.com

Hi I am learning transaction and isolation levels. I tried to use read_committed in one thread and then in another thread insert some data into a table. the reader thread is blocked and waits until the first thread commit the transaction to complete the select statement. What I can not understand is: shouldn't the second thread only read what is already ...

9. When commit transaction    coderanch.com

I have a table containing records with a status = not_processed. I have to do a job that take each record and try to call a workflow to get a value , update this record with the value and set status=Processed. The processing of a record is independant of the other records . So i will have to use one transaction ...





10. Java/Oracle JDBC transaction management and committing sessions    coderanch.com

import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class TestClass { public static void main(String args[]) throws ClassNotFoundException, SQLException{ Connection database; Class.forName("oracle.jdbc.driver.OracleDriver"); database = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:mydb", "user", "pass"); if (database.getAutoCommit()) database.setAutoCommit(false); String insertParent = "Insert into ParentTable (parentId,name,value) values(parentSeq.nextval,?,?)"; String insertChild = "Insert into ChildTable (childId,parentId,value) values(childSeq.nextval,?,?)"; PreparedStatement addParentStmt = null; PreparedStatement addChildStmt = null; //Add the ...