rollback « Transaction « Java Database Q&A

1. Transaction rollback and web services

Given an example of calling two web services methods from a session bean, what if an exception is thrown between the calls to two methods? In the case of not calling ...

2. NullPointerException while adding data to the database from online page

I am getting a NullPointerException Exception while adding data from the online JSP page. The error description is as follows:

javax.transaction.TransactionRolledbackException: CORBA
TRANSACTION_ROLLEDBACK 0x0 No; nested exception is:
javax.transaction.TransactionRolledbackException: ; nested exception is:
java.lang.NullPointerException vmcid: 0x0 ...

3. Dealing with RollbackException in Java

Hey, Is there any way to "replay" transaction? I mean, sometimes I get RollbackException and rollback the transaction. Can I then "clone" the transaction and try again, or once rollback is ...

4. What is proper code pattern to finalize transactions in Java (rollback on exception and commit on success)?

I'm looking for generic code pattern to properly handle transaction with respect to possible exception. I assume there is common code pattern for that, no matter what concrete kind of transaction ...

5. Grails 1.2.0 - Forcing a service to rollback

I have a service class that calls other utility classes. These classes themselves sometimes save domain objects and flush them (ex: new User(...).save(flush:true)). I'm calling my service class from a test. Is ...

6. EJB3 transaction rollback

I'm using CMT in EJB3 state-less session beans. Also I've created my own Exception having the annotation "@ApplicationException (rollback=true)".

  1. Do I have to use "context.setRollbackOnly()" when I want to rollback the transaction?
  2. Can ...

7. What is the best way to restore(rollback) data in an application to a specified state(date)?

An example would set the context right, the example below captures the various states of the entity, which needs to be reverted(rolled back) . State 1 - Recorded on 01-Mar-2010

Column1 Column2
Data1  ...

8. In JDBC, when autocommit is false and no explicit savepoints have been set, is it good style or a waste to rollback?

Say you have the following code:

Connection conn;
   conn = ... // get connection

   ... // Do some modification queries and logic

} ...

9. Liquibase Rollback Custom SQL

I can't figure out how to rollback custom Sql within a changeset. Any thoughts? I'd like to do this:

<changeSet author="Charlie White" id="15" runAlways="false" runOnChange="false" failOnError="true">

10. How do I transactionally poll a database queue table with rollback?

I wish to setup a database table that will be used as a message queue. The table will have messages inserted into it with a unique id and a timestamp and ...

11. UserTransaction issue in java

I have existing project which uses 2 database (DB2),and the records which are saved in the 2 databases are related.So the transactions need to be maintained.Eg whenever a new thing is ...

12. SQL batch update - rollback on "CREATE TABLE"?

I have a method for upgrading DB:

private void executeUpdateBatch(String... sql) throws SQLException {
    JdbcConnection connJbdc = new JdbcConnectionImpl();
    Connection conn = connJbdc.getConnection();

13. Transaction rollback in stateless session EJB 3.0

I have a stateless session EJB as per 3.0 spec.

/*Remote Interface*/

import java.sql.SQLException;
import java.util.Collection;

import javax.ejb.Remote;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.naming.NamingException;


public interface ProductionDataChangesRequestsRemote {

    public boolean ...

14. Signal a rollback from a JMS MessageListener

I've been working with JMS and ActiveMQ. Everything is working wonders. I am not using spring, nor can I. The interface javax.jms.MessageListener has only one method, onMessage. From within a implementation, there ...

15. Illegal operation exception while trying rollback..

Hi, I am developing some session beans with WSAD4.0 , JDBC for OracleThin(, Oracle 8.05. In one of the session bean, I am trying to use callablestatement for updating a table. I am getting an error. When I try the same statmenet directly in SQL, I get an exception saying ORA-01031: insufficient privileges. I need to know how to xlate this ...

16. commit() and rollback() problem!

Hello All, I am still having problems with my code. I want to be able to insert data from a file into a database but when i spell one of the column names wrong (on pupose), it inserts the data that is correct then thows the exception, I dont want this as I want the exception to be thown first. If ...

17. how to rollback in java

You can do it using JDBC. When you create a Connection object it is set to autocommit by default. First of all after creating the Connection object set the autocommit to false. Connection con = DriverManager.getConnection(params); con.setAutoCommmit(false); Now you insert the records in 1st table and then second table in try catch block. Try{ Connection con = DriverManager.getConnection(params); con.setAutoCommmit(false); //insert records ...

18. rollback, save point .....

Hi all. I have some questions about transactions. 1. as you know, getErrorCode( ) method returns a vendor's error code, so maybe differ from database to other. does getSQLState( ) method return a fixed value for a specific problem ? I mean, I have MYSQL database and I shut it down, when catching the SQLException and calling getSQLState( ) method, I ...

19. use of commit() and rollback()

20. Setting autoCommit(false)/Rollback()

Thanks David, I think there must be a way for me to configure the Connection Pool so that the connection is never in the global state because that is what is preventing me from setting con.setAutoCommit(false) etc...I just don't know how to do it. As for setting autoCommit() on some connections and not on others, that was never my intention. I ...

21. Weird rollback behaviour

Hello all I'm suffering a strange behaviour using transactions. The enviroment is: Java 1.3.1 (not under my control) JDBC driver: IBM provided for connecting to DB2 in a AS/400 Using struts with autocommit = false. Problem: The database state is inconsistent with the fact that a rollback was made. The code structure is more or less this... (not real code, just ...

22. Rollback Problem

Hi , I am using a JDBC connection and inserting an entry into a table. After that i am committing the connection and coming back. After i commit the connection if any error comes in further processing, the entry that i have inserted is getting deleted from the table. Is it possible that an entry to get deleted after i commit ...

23. rollback transaction for single phase commit

I have requirement that i need to insert into two databases i.e., sql and DB2. But our code not using two phase commit. The requirement: i am inserting into sql-database table first by creating one transaction and doing commit after that, and next creating another transaction to inert into DB2-database table and doing commit. Problem is: if it fails in second ...

24. Commit & Rollback using java?

25. commit() and rollback() in a finally block

Hi, according to the Java coding conventions, isn't it appropriate to use the commit() or rollback() in a finally block? Please see the following code which is a portion of my program. Please let me know is it appropriate. finally { try { if (dbConnection != null) { if (errorFound) { dbConnection.rollback(); } else { dbConnection.commit(); } dbConnection.close(); dbConnection = null; ...

26. .commit() and .rollback()

27. commit and rollback in transaction

28. I have name of a savepoint, can i rollback to that savepoint?

Hi Thank you for reading my post I have name of a savepoint in my method and connection which that savepoint belongs to. Now what i need it to rollback to that savepoint but problem is that Connection object rollback method does not accept savepoint name and it just accept savepoint Object to rollback to it. So, is there any way ...

29. Rollback a delete statement..

30. Using commit and rollback

If I am in non-commit mode and I try to commit a database transaction using the commit object, and the commit fails, will all queries in that commit be undone, or do I need to call rollback()? For example, say I want to commit 10 queries, but in the middle of committing them, I lose my database connection. Will the ones ...

31. How to handle transaction Rollback on Exception

Hi, I have a web application that is implemented using Spring, Hibernate, and Struts. I trying to handle rollbacks with an exception occurs and I have no idea what approach to take (...since I haven't done this before). Here's are the steps of what it's doing: Page 1. User chooses a business package. Page 2. User enters their business details (backend: ...

32. How to rollback multiple prepared statements

Hi Everyone, I have to insert records to multiple tables at one go or in one batch. For example, my tables are: A, B, C I have to use the prepared statement for executing an insert statement which in this case, there will be one prepared statement for each table. The requirement is if one table fails to insert a record, ...

33. problem with rollback()

34. problem of rollback()

Hi i have an application of sending an card from one employee to other. On page 1:Employee selectes an Card page 2:He fills the info like his name,mail Id ,reciptents mail id ,name etc.. When he clicks on "Send" button the data base table gets updated with the information filled by the person on the page and then the mail is ...

35. Commit & Rollback in Java?

Thank you Jeanne. As a matter of interest, which class(es) do those methods belong to? Are they in the Java API? I would try to test it now if I were further advanced in my Java studies, but will have to wait until i know a few more things. I have not learnt how to call SQL in Java yet, nor ...

36. Rollback when any error occurrs

37. Cannot invoke a rollback operation when the AutoCommit mode is set to "true"

I am using ScriptRunner class For running SQL scripts For SQL SERVER 2005 Data base. It is giving me following error for insertion queries other queries for deletion or selection is working fine. Cannot invoke a rollback operation when the AutoCommit mode is set to "true". at Source) at Source) at com.ibatis.common.jdbc.ScriptRunner.runScript( at com.ibatis.common.jdbc.ScriptRunner.runScript( Please help what can ...

38. why my rollback doesn't work?

hi everyone, I wrote a piece of code to test the rollback function.However, it doesn't work, can some one scanning through my code and tell me what the problem is . import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Statement; /*Date 07 April 2010 * this class added to handled the Mysql transcations, with Begin Commit or Rollback. * * */ public ...

39. AutoCommit(False) and rollback bst practise

If i have two tables TABLE-A and TABLE-B both of them has to be inserted or updated in transaction , if insert both insert , and if any error in insert of on table rollback from both the tables. So my question is which is the best practise try{ con = DriverManager.getConnection(); con.setAutoCommit(false); insert in TABLE-A insert in TABLE-B con.commit(); }catch(Exception ...

40. Looping through PreparedStatement executeBatch for Commit or rollback

If one of the commands in a batch update fails to execute properly, this method throws a BatchUpdateException, and a JDBC driver may or may not continue to process the remaining commands in the batch. However, the driver's behavior must be consistent with a particular DBMS, either always continuing to process commands or never continuing to process commands. If the driver ...

41. Reverting changes on objects after a database rollback

Hi, I have one specific object that is persisted in two tables of the database. The database contains internationalized data, so one table, say TABLE_X, keeps the non-internationalized data (references to other tables, and some numbers), and the other, say TABLE_X_DETAILS keeps the internationalized (mainly descriptions in different languages). I have a java class, say CLASS_X, which must be persisted. When ...

42. Query about rollback() method

Are you setting auto commit off? In my experience, rollback() or commit() is usually the last call you make on a database before releasing the connection. Do you know the cause of the exception? Is this a SQL exception? If you can avoid the exception by checking existing parameters, that is preferable then letting exceptions happen.

43. Rollback the transcation

44. Local transaction Rolled-back

Error Page Exception: Error Message: /error.jsp Error Code: 0 Target Servlet: null Error Stack: /error.jsp at at$JspServletWrapper.loadIfNecessary( at$JspServletWrapper.service( at at at javax.servlet.http.HttpServlet.service( at at at at at at at at at at at at at at at at at ...