Multiple database inserts/updates and commit - Weblogic

This is a discussion on Multiple database inserts/updates and commit - Weblogic ; Hi, I am want to do number of database inserts and update calls from my code. Every subsequent insert or update call is dependent on the success of the preceding call. I do not want to commit my inserts or ...

+ Reply to Thread
Results 1 to 8 of 8

Thread: Multiple database inserts/updates and commit

  1. Multiple database inserts/updates and commit


    Hi,
    I am want to do number of database inserts and update calls from my code. Every
    subsequent insert or update call is dependent on the success of the preceding
    call. I do not want to commit my inserts or updates until the end (and only if
    everying goes okay) and if there is a problem, I want a total rollback. I am not
    sure how do I do that. I am using weblogic7 sp5 and "Emulate Two-Phase Commit
    for non-XA Driver" check box has been checked for the "Tx Data Source" I am using.
    The way I am planning to do is something like following. If there is a problem
    in my "InsertRowInTable_3" call, does this gaurentee a rollback and undo my first
    update call "UpdateTable_1()" ? Any suggestions??
    Thanks in advance.

    ......
    try{
    UpdateTable_1();
    InsertRowInTable_3()
    UpdateTable_4();
    }catch (Exception e){
    System.out.println("Exception caught");
    e.printStackTrace();
    }

  2. Re: Multiple database inserts/updates and commit



    Ashish wrote:

    > Hi,
    > I am want to do number of database inserts and update calls from my code. Every
    > subsequent insert or update call is dependent on the success of the preceding
    > call. I do not want to commit my inserts or updates until the end (and only if
    > everying goes okay) and if there is a problem, I want a total rollback. I am not
    > sure how do I do that. I am using weblogic7 sp5 and "Emulate Two-Phase Commit
    > for non-XA Driver" check box has been checked for the "Tx Data Source" I am using.
    > The way I am planning to do is something like following. If there is a problem
    > in my "InsertRowInTable_3" call, does this gaurentee a rollback and undo my first
    > update call "UpdateTable_1()" ? Any suggestions??
    > Thanks in advance.



    >
    > .....
    > try{
    > UpdateTable_1();
    > InsertRowInTable_3()
    > UpdateTable_4();
    > }catch (Exception e){
    > System.out.println("Exception caught");
    > e.printStackTrace();
    > }


    If this is in a transactional EJB, or if in the context of a running UserTransaction
    then just do a rollback on the tx in the catch block.


  3. Re: Multiple database inserts/updates and commit


    Joe,
    Thank you for your quick reply.
    I am doing these insert/update calls from a message driven bean. Are you suggesting
    that I should get a UserTranscation (myMsgContext.getUserTransaction() )and do
    a rollback in the catch block?
    I do not explicitly do "commit()" in my insert/update calls either. Now I am
    confused, I was assuming that after I do each insert/update call (within the same
    try block), the transaction gets commited right after the call is successful.
    Is my assumption wrong?

    Since I did not explicitly have to do "commit()", do I even have to worry about
    doing "rollback()"? Wouldn't weblogic just handle the rollback for me as long
    as all the transactions are happening in the same MessageDrivenContext?

    Joe Weinstein wrote:
    >
    >
    >Ashish wrote:
    >
    >> Hi,
    >> I am want to do number of database inserts and update calls from my

    >code. Every
    >> subsequent insert or update call is dependent on the success of the

    >preceding
    >> call. I do not want to commit my inserts or updates until the end

    >(and only if
    >> everying goes okay) and if there is a problem, I want a total rollback.

    >I am not
    >> sure how do I do that. I am using weblogic7 sp5 and "Emulate Two-Phase

    >Commit
    >> for non-XA Driver" check box has been checked for the "Tx Data Source"

    >I am using.
    >> The way I am planning to do is something like following. If there is

    >a problem
    >> in my "InsertRowInTable_3" call, does this gaurentee a rollback and

    >undo my first
    >> update call "UpdateTable_1()" ? Any suggestions??
    >> Thanks in advance.

    >
    >
    >>
    >> .....
    >> try{
    >> UpdateTable_1();
    >> InsertRowInTable_3()
    >> UpdateTable_4();
    >> }catch (Exception e){
    >> System.out.println("Exception caught");
    >> e.printStackTrace();
    >> }

    >
    >If this is in a transactional EJB, or if in the context of a running
    >UserTransaction
    >then just do a rollback on the tx in the catch block.
    >



  4. Re: Multiple database inserts/updates and commit



    Ashish wrote:

    > Joe,
    > Thank you for your quick reply.
    > I am doing these insert/update calls from a message driven bean. Are you suggesting
    > that I should get a UserTranscation (myMsgContext.getUserTransaction() )and do
    > a rollback in the catch block?
    > I do not explicitly do "commit()" in my insert/update calls either. Now I am
    > confused, I was assuming that after I do each insert/update call (within the same
    > try block), the transaction gets commited right after the call is successful.
    > Is my assumption wrong?
    >
    > Since I did not explicitly have to do "commit()", do I even have to worry about
    > doing "rollback()"? Wouldn't weblogic just handle the rollback for me as long
    > as all the transactions are happening in the same MessageDrivenContext?



    H. You'll have to read up on transactions and weblogic and jdbc.
    If your MDB is defined as trasnactional, and you get your jdbc connection
    from a transactional DataSource, the connection will be in autoCommit(false) mode.
    There is an ongoing UserTransaction which will be committed when the method completes
    unles the method throws the right sort of exception (see the ejb+tx spec) or if you
    roll back the tx.
    Joe

    > Joe Weinstein wrote:
    >
    >>
    >>Ashish wrote:
    >>
    >>
    >>>Hi,
    >>>I am want to do number of database inserts and update calls from my

    >>
    >>code. Every
    >>
    >>>subsequent insert or update call is dependent on the success of the

    >>
    >>preceding
    >>
    >>>call. I do not want to commit my inserts or updates until the end

    >>
    >>(and only if
    >>
    >>>everying goes okay) and if there is a problem, I want a total rollback.

    >>
    >>I am not
    >>
    >>>sure how do I do that. I am using weblogic7 sp5 and "Emulate Two-Phase

    >>
    >>Commit
    >>
    >>>for non-XA Driver" check box has been checked for the "Tx Data Source"

    >>
    >>I am using.
    >>
    >>>The way I am planning to do is something like following. If there is

    >>
    >>a problem
    >>
    >>>in my "InsertRowInTable_3" call, does this gaurentee a rollback and

    >>
    >>undo my first
    >>
    >>>update call "UpdateTable_1()" ? Any suggestions??
    >>>Thanks in advance.

    >>
    >>
    >>>.....
    >>>try{
    >>> UpdateTable_1();
    >>> InsertRowInTable_3()
    >>> UpdateTable_4();
    >>>}catch (Exception e){
    >>> System.out.println("Exception caught");
    >>> e.printStackTrace();
    >>>}

    >>
    >>If this is in a transactional EJB, or if in the context of a running
    >>UserTransaction
    >>then just do a rollback on the tx in the catch block.
    >>

    >
    >



  5. Re: Multiple database inserts/updates and commit


    OK, I am still having problem with this.
    My MDB is a transactional bean:
    ....
    Container
    .....
    .....
    Required
    .....

    So, this means my database connection is in setAutoCommit(false) mode. But When
    I do a multiple inserts into the database. The first insert call executes fine,
    but the second one catches an exception and the third one also executes fine.
    I want all the database transactions to rollback since the second insert call
    failed, even though the first and the third insert calls executed OK, but it
    does not. I am also calling messageDrivenContext.setRollbackOnly() and also doing
    connection.rollback(). Non of these calls have any effect. I am using the one
    and the same connection throughout . What am I doing wrong? I even tried setAutoCommit(false)
    but the Weblogic did not like it saying that I could not do that in a distributed
    transaction.
    Any suggestions please?



    Joe Weinstein wrote:
    >
    >
    >Ashish wrote:
    >
    >> Joe,
    >> Thank you for your quick reply.
    >> I am doing these insert/update calls from a message driven bean. Are

    >you suggesting
    >> that I should get a UserTranscation (myMsgContext.getUserTransaction()

    >)and do
    >> a rollback in the catch block?
    >> I do not explicitly do "commit()" in my insert/update calls either.

    >Now I am
    >> confused, I was assuming that after I do each insert/update call (within

    >the same
    >> try block), the transaction gets commited right after the call is successful.
    >> Is my assumption wrong?
    >>
    >> Since I did not explicitly have to do "commit()", do I even have to

    >worry about
    >> doing "rollback()"? Wouldn't weblogic just handle the rollback for

    >me as long
    >> as all the transactions are happening in the same MessageDrivenContext?

    >
    >
    >H. You'll have to read up on transactions and weblogic and jdbc.
    >If your MDB is defined as trasnactional, and you get your jdbc connection
    >from a transactional DataSource, the connection will be in autoCommit(false)
    >mode.
    >There is an ongoing UserTransaction which will be committed when the
    >method completes
    >unles the method throws the right sort of exception (see the ejb+tx spec)
    >or if you
    >roll back the tx.
    >Joe
    >
    >> Joe Weinstein wrote:
    >>
    >>>
    >>>Ashish wrote:
    >>>
    >>>
    >>>>Hi,
    >>>>I am want to do number of database inserts and update calls from

    >my
    >>>
    >>>code. Every
    >>>
    >>>>subsequent insert or update call is dependent on the success of the
    >>>
    >>>preceding
    >>>
    >>>>call. I do not want to commit my inserts or updates until the end
    >>>
    >>>(and only if
    >>>
    >>>>everying goes okay) and if there is a problem, I want a total rollback.
    >>>
    >>>I am not
    >>>
    >>>>sure how do I do that. I am using weblogic7 sp5 and "Emulate Two-Phase
    >>>
    >>>Commit
    >>>
    >>>>for non-XA Driver" check box has been checked for the "Tx Data Source"
    >>>
    >>>I am using.
    >>>
    >>>>The way I am planning to do is something like following. If there

    >is
    >>>
    >>>a problem
    >>>
    >>>>in my "InsertRowInTable_3" call, does this gaurentee a rollback and
    >>>
    >>>undo my first
    >>>
    >>>>update call "UpdateTable_1()" ? Any suggestions??
    >>>>Thanks in advance.
    >>>
    >>>
    >>>>.....
    >>>>try{
    >>>> UpdateTable_1();
    >>>> InsertRowInTable_3()
    >>>> UpdateTable_4();
    >>>>}catch (Exception e){
    >>>> System.out.println("Exception caught");
    >>>> e.printStackTrace();
    >>>>}
    >>>
    >>>If this is in a transactional EJB, or if in the context of a running
    >>>UserTransaction
    >>>then just do a rollback on the tx in the catch block.
    >>>

    >>
    >>

    >



  6. Re: Multiple database inserts/updates and commit



    Ashish wrote:

    > OK, I am still having problem with this.
    > My MDB is a transactional bean:
    > ...
    > Container
    > ....
    > ....
    > Required
    > ....
    >
    > So, this means my database connection is in setAutoCommit(false) mode. But When
    > I do a multiple inserts into the database. The first insert call executes fine,
    > but the second one catches an exception


    If you catch an exception, we won't do anything about it. You should then obtain
    the UserTransaction and setRollbackOnly(). The EJB spec discusses which exceptions
    do or do not cause a tx to roll back automatically.
    Joe

    and the third one also executes fine.
    > I want all the database transactions to rollback since the second insert call
    > failed, even though the first and the third insert calls executed OK, but it
    > does not. I am also calling messageDrivenContext.setRollbackOnly() and also doing
    > connection.rollback(). Non of these calls have any effect. I am using the one
    > and the same connection throughout . What am I doing wrong? I even tried setAutoCommit(false)
    > but the Weblogic did not like it saying that I could not do that in a distributed
    > transaction.
    > Any suggestions please?
    >
    >
    >
    > Joe Weinstein wrote:
    >
    >>
    >>Ashish wrote:
    >>
    >>
    >>>Joe,
    >>>Thank you for your quick reply.
    >>>I am doing these insert/update calls from a message driven bean. Are

    >>
    >>you suggesting
    >>
    >>>that I should get a UserTranscation (myMsgContext.getUserTransaction()

    >>
    >>)and do
    >>
    >>>a rollback in the catch block?
    >>>I do not explicitly do "commit()" in my insert/update calls either.

    >>
    >>Now I am
    >>
    >>>confused, I was assuming that after I do each insert/update call (within

    >>
    >>the same
    >>
    >>>try block), the transaction gets commited right after the call is successful.
    >>>Is my assumption wrong?
    >>>
    >>>Since I did not explicitly have to do "commit()", do I even have to

    >>
    >>worry about
    >>
    >>> doing "rollback()"? Wouldn't weblogic just handle the rollback for

    >>
    >>me as long
    >>
    >>>as all the transactions are happening in the same MessageDrivenContext?

    >>
    >>
    >>H. You'll have to read up on transactions and weblogic and jdbc.
    >>If your MDB is defined as trasnactional, and you get your jdbc connection

    >
    >>from a transactional DataSource, the connection will be in autoCommit(false)

    >
    >>mode.
    >>There is an ongoing UserTransaction which will be committed when the
    >>method completes
    >>unles the method throws the right sort of exception (see the ejb+tx spec)
    >>or if you
    >>roll back the tx.
    >>Joe
    >>
    >>
    >>>Joe Weinstein wrote:
    >>>
    >>>
    >>>>Ashish wrote:
    >>>>
    >>>>
    >>>>
    >>>>>Hi,
    >>>>>I am want to do number of database inserts and update calls from

    >>
    >>my
    >>
    >>>>code. Every
    >>>>
    >>>>
    >>>>>subsequent insert or update call is dependent on the success of the
    >>>>
    >>>>preceding
    >>>>
    >>>>
    >>>>>call. I do not want to commit my inserts or updates until the end
    >>>>
    >>>>(and only if
    >>>>
    >>>>
    >>>>>everying goes okay) and if there is a problem, I want a total rollback.
    >>>>
    >>>>I am not
    >>>>
    >>>>
    >>>>>sure how do I do that. I am using weblogic7 sp5 and "Emulate Two-Phase
    >>>>
    >>>>Commit
    >>>>
    >>>>
    >>>>>for non-XA Driver" check box has been checked for the "Tx Data Source"
    >>>>
    >>>>I am using.
    >>>>
    >>>>
    >>>>>The way I am planning to do is something like following. If there

    >>
    >>is
    >>
    >>>>a problem
    >>>>
    >>>>
    >>>>>in my "InsertRowInTable_3" call, does this gaurentee a rollback and
    >>>>
    >>>>undo my first
    >>>>
    >>>>
    >>>>>update call "UpdateTable_1()" ? Any suggestions??
    >>>>>Thanks in advance.
    >>>>
    >>>>
    >>>>>.....
    >>>>>try{
    >>>>> UpdateTable_1();
    >>>>> InsertRowInTable_3()
    >>>>> UpdateTable_4();
    >>>>>}catch (Exception e){
    >>>>> System.out.println("Exception caught");
    >>>>> e.printStackTrace();
    >>>>>}
    >>>>
    >>>>If this is in a transactional EJB, or if in the context of a running
    >>>>UserTransaction
    >>>>then just do a rollback on the tx in the catch block.
    >>>>
    >>>
    >>>

    >



  7. Re: Multiple database inserts/updates and commit


    Thanks Joe for your quick reply.
    I did userTransaction.setRollBackOnly(), but this may not be the guy I am after.
    It rolled back my database changes plus the message itself (I could see the message
    rolling back infinitely in the console) . I want just the databases changes to
    rollback not the message itself. I'd like to drop the message if I have to rollback
    my database changes.
    My MDB uses container-managed transaction. Is my problem is due to Container managed
    transaction?
    Thanks

    Joe Weinstein wrote:
    >
    >
    >Ashish wrote:
    >
    >> OK, I am still having problem with this.
    >> My MDB is a transactional bean:
    >> ...
    >> Container
    >> ....
    >> ....
    >> Required
    >> ....
    >>
    >> So, this means my database connection is in setAutoCommit(false) mode.

    >But When
    >> I do a multiple inserts into the database. The first insert call executes

    >fine,
    >> but the second one catches an exception

    >
    >If you catch an exception, we won't do anything about it. You should
    >then obtain
    >the UserTransaction and setRollbackOnly(). The EJB spec discusses which
    >exceptions
    >do or do not cause a tx to roll back automatically.
    >Joe
    >
    > and the third one also executes fine.
    >> I want all the database transactions to rollback since the second

    >insert call
    >> failed, even though the first and the third insert calls executed

    >OK, but it
    >> does not. I am also calling messageDrivenContext.setRollbackOnly()

    >and also doing
    >> connection.rollback(). Non of these calls have any effect. I am using

    >the one
    >> and the same connection throughout . What am I doing wrong? I even

    >tried setAutoCommit(false)
    >> but the Weblogic did not like it saying that I could not do that in

    >a distributed
    >> transaction.
    >> Any suggestions please?
    >>
    >>
    >>
    >> Joe Weinstein wrote:
    >>
    >>>
    >>>Ashish wrote:
    >>>
    >>>
    >>>>Joe,
    >>>>Thank you for your quick reply.
    >>>>I am doing these insert/update calls from a message driven bean. Are
    >>>
    >>>you suggesting
    >>>
    >>>>that I should get a UserTranscation (myMsgContext.getUserTransaction()
    >>>
    >>>)and do
    >>>
    >>>>a rollback in the catch block?
    >>>>I do not explicitly do "commit()" in my insert/update calls either.
    >>>
    >>>Now I am
    >>>
    >>>>confused, I was assuming that after I do each insert/update call (within
    >>>
    >>>the same
    >>>
    >>>>try block), the transaction gets commited right after the call is

    >successful.
    >>>>Is my assumption wrong?
    >>>>
    >>>>Since I did not explicitly have to do "commit()", do I even have to
    >>>
    >>>worry about
    >>>
    >>>> doing "rollback()"? Wouldn't weblogic just handle the rollback for
    >>>
    >>>me as long
    >>>
    >>>>as all the transactions are happening in the same MessageDrivenContext?
    >>>
    >>>
    >>>H. You'll have to read up on transactions and weblogic and jdbc.
    >>>If your MDB is defined as trasnactional, and you get your jdbc connection

    >>
    >>>from a transactional DataSource, the connection will be in autoCommit(false)

    >>
    >>>mode.
    >>>There is an ongoing UserTransaction which will be committed when the
    >>>method completes
    >>>unles the method throws the right sort of exception (see the ejb+tx

    >spec)
    >>>or if you
    >>>roll back the tx.
    >>>Joe
    >>>
    >>>
    >>>>Joe Weinstein wrote:
    >>>>
    >>>>
    >>>>>Ashish wrote:
    >>>>>
    >>>>>
    >>>>>
    >>>>>>Hi,
    >>>>>>I am want to do number of database inserts and update calls from

    >
    >>>
    >>>my
    >>>
    >>>>>code. Every
    >>>>>
    >>>>>
    >>>>>>subsequent insert or update call is dependent on the success of

    >the
    >>>>>
    >>>>>preceding
    >>>>>
    >>>>>
    >>>>>>call. I do not want to commit my inserts or updates until the end
    >>>>>
    >>>>>(and only if
    >>>>>
    >>>>>
    >>>>>>everying goes okay) and if there is a problem, I want a total rollback.
    >>>>>
    >>>>>I am not
    >>>>>
    >>>>>
    >>>>>>sure how do I do that. I am using weblogic7 sp5 and "Emulate Two-Phase
    >>>>>
    >>>>>Commit
    >>>>>
    >>>>>
    >>>>>>for non-XA Driver" check box has been checked for the "Tx Data Source"
    >>>>>
    >>>>>I am using.
    >>>>>
    >>>>>
    >>>>>>The way I am planning to do is something like following. If there
    >>>
    >>>is
    >>>
    >>>>>a problem
    >>>>>
    >>>>>
    >>>>>>in my "InsertRowInTable_3" call, does this gaurentee a rollback

    >and
    >>>>>
    >>>>>undo my first
    >>>>>
    >>>>>
    >>>>>>update call "UpdateTable_1()" ? Any suggestions??
    >>>>>>Thanks in advance.
    >>>>>
    >>>>>
    >>>>>>.....
    >>>>>>try{
    >>>>>> UpdateTable_1();
    >>>>>> InsertRowInTable_3()
    >>>>>> UpdateTable_4();
    >>>>>>}catch (Exception e){
    >>>>>> System.out.println("Exception caught");
    >>>>>> e.printStackTrace();
    >>>>>>}
    >>>>>
    >>>>>If this is in a transactional EJB, or if in the context of a running
    >>>>>UserTransaction
    >>>>>then just do a rollback on the tx in the catch block.
    >>>>>
    >>>>
    >>>>

    >>

    >



  8. Re: Multiple database inserts/updates and commit



    Ashish wrote:

    > Thanks Joe for your quick reply.
    > I did userTransaction.setRollBackOnly(), but this may not be the guy I am after.
    > It rolled back my database changes plus the message itself (I could see the message
    > rolling back infinitely in the console) . I want just the databases changes to
    > rollback not the message itself. I'd like to drop the message if I have to rollback
    > my database changes.
    > My MDB uses container-managed transaction. Is my problem is due to Container managed
    > transaction?
    > Thanks


    Well, you'll have to structure separate transactions if you want a message to remain,
    but rollback DBMS updates. They can't be the same tx, unless you were to know all the
    updates you had done, and undo them manually instead of asking the DBMS to roll them back.
    Some DBMSes have savepoints, where you can roll back part of a transaction, but still keep
    it open... I suggest maping out your needs in the transaction newsgroup. They may be able
    to generate a way to do it...
    Joe
    >
    > Joe Weinstein wrote:
    >
    >>
    >>Ashish wrote:
    >>
    >>
    >>>OK, I am still having problem with this.
    >>>My MDB is a transactional bean:
    >>>...
    >>>Container
    >>>....
    >>>....
    >>>Required
    >>>....
    >>>
    >>>So, this means my database connection is in setAutoCommit(false) mode.

    >>
    >>But When
    >>
    >>>I do a multiple inserts into the database. The first insert call executes

    >>
    >>fine,
    >>
    >>>but the second one catches an exception

    >>
    >>If you catch an exception, we won't do anything about it. You should
    >>then obtain
    >>the UserTransaction and setRollbackOnly(). The EJB spec discusses which
    >>exceptions
    >>do or do not cause a tx to roll back automatically.
    >>Joe
    >>
    >> and the third one also executes fine.
    >>
    >>>I want all the database transactions to rollback since the second

    >>
    >>insert call
    >>
    >>>failed, even though the first and the third insert calls executed

    >>
    >>OK, but it
    >>
    >>>does not. I am also calling messageDrivenContext.setRollbackOnly()

    >>
    >>and also doing
    >>
    >>>connection.rollback(). Non of these calls have any effect. I am using

    >>
    >>the one
    >>
    >>>and the same connection throughout . What am I doing wrong? I even

    >>
    >>tried setAutoCommit(false)
    >>
    >>>but the Weblogic did not like it saying that I could not do that in

    >>
    >>a distributed
    >>
    >>>transaction.
    >>>Any suggestions please?
    >>>
    >>>
    >>>
    >>>Joe Weinstein wrote:
    >>>
    >>>
    >>>>Ashish wrote:
    >>>>
    >>>>
    >>>>
    >>>>>Joe,
    >>>>>Thank you for your quick reply.
    >>>>>I am doing these insert/update calls from a message driven bean. Are
    >>>>
    >>>>you suggesting
    >>>>
    >>>>
    >>>>>that I should get a UserTranscation (myMsgContext.getUserTransaction()
    >>>>
    >>>>)and do
    >>>>
    >>>>
    >>>>>a rollback in the catch block?
    >>>>>I do not explicitly do "commit()" in my insert/update calls either.
    >>>>
    >>>>Now I am
    >>>>
    >>>>
    >>>>>confused, I was assuming that after I do each insert/update call (within
    >>>>
    >>>>the same
    >>>>
    >>>>
    >>>>>try block), the transaction gets commited right after the call is

    >>
    >>successful.
    >>
    >>>>>Is my assumption wrong?
    >>>>>
    >>>>>Since I did not explicitly have to do "commit()", do I even have to
    >>>>
    >>>>worry about
    >>>>
    >>>>
    >>>>>doing "rollback()"? Wouldn't weblogic just handle the rollback for
    >>>>
    >>>>me as long
    >>>>
    >>>>
    >>>>>as all the transactions are happening in the same MessageDrivenContext?
    >>>>
    >>>>
    >>>>H. You'll have to read up on transactions and weblogic and jdbc.
    >>>>If your MDB is defined as trasnactional, and you get your jdbc connection
    >>>
    >>>>from a transactional DataSource, the connection will be in autoCommit(false)
    >>>
    >>>
    >>>>mode.
    >>>>There is an ongoing UserTransaction which will be committed when the
    >>>>method completes
    >>>>unles the method throws the right sort of exception (see the ejb+tx

    >>
    >>spec)
    >>
    >>>>or if you
    >>>>roll back the tx.
    >>>>Joe
    >>>>
    >>>>
    >>>>
    >>>>>Joe Weinstein wrote:
    >>>>>
    >>>>>
    >>>>>
    >>>>>>Ashish wrote:
    >>>>>>
    >>>>>>
    >>>>>>
    >>>>>>
    >>>>>>>Hi,
    >>>>>>>I am want to do number of database inserts and update calls from

    >>
    >>>>my
    >>>>
    >>>>
    >>>>>>code. Every
    >>>>>>
    >>>>>>
    >>>>>>
    >>>>>>>subsequent insert or update call is dependent on the success of

    >>
    >>the
    >>
    >>>>>>preceding
    >>>>>>
    >>>>>>
    >>>>>>
    >>>>>>>call. I do not want to commit my inserts or updates until the end
    >>>>>>
    >>>>>>(and only if
    >>>>>>
    >>>>>>
    >>>>>>
    >>>>>>>everying goes okay) and if there is a problem, I want a total rollback.
    >>>>>>
    >>>>>>I am not
    >>>>>>
    >>>>>>
    >>>>>>
    >>>>>>>sure how do I do that. I am using weblogic7 sp5 and "Emulate Two-Phase
    >>>>>>
    >>>>>>Commit
    >>>>>>
    >>>>>>
    >>>>>>
    >>>>>>>for non-XA Driver" check box has been checked for the "Tx Data Source"
    >>>>>>
    >>>>>>I am using.
    >>>>>>
    >>>>>>
    >>>>>>
    >>>>>>>The way I am planning to do is something like following. If there
    >>>>
    >>>>is
    >>>>
    >>>>
    >>>>>>a problem
    >>>>>>
    >>>>>>
    >>>>>>
    >>>>>>>in my "InsertRowInTable_3" call, does this gaurentee a rollback

    >>
    >>and
    >>
    >>>>>>undo my first
    >>>>>>
    >>>>>>
    >>>>>>
    >>>>>>>update call "UpdateTable_1()" ? Any suggestions??
    >>>>>>>Thanks in advance.
    >>>>>>
    >>>>>>
    >>>>>>>.....
    >>>>>>>try{
    >>>>>>> UpdateTable_1();
    >>>>>>> InsertRowInTable_3()
    >>>>>>> UpdateTable_4();
    >>>>>>>}catch (Exception e){
    >>>>>>> System.out.println("Exception caught");
    >>>>>>> e.printStackTrace();
    >>>>>>>}
    >>>>>>
    >>>>>>If this is in a transactional EJB, or if in the context of a running
    >>>>>>UserTransaction
    >>>>>>then just do a rollback on the tx in the catch block.
    >>>>>>
    >>>>>
    >>>>>

    >



+ Reply to Thread