Transaction...

Discussion in 'Java' started by gbattine, Nov 10, 2006.

  1. gbattine

    gbattine Guest

    Hi guys,
    excuse me if i open another post on the same argument but now i've
    cleared my problem,so i think a new discussion can be useful. Thanks
    for precedent replies.

    I've to use a transaction in my jsf application.
    My problem is:
    User insert an experiment into db using 6 different web pages, each
    page create one or more prepared statements.
    I want the inserting in my db tables happens into a transaction.
    I've done this.

    The first bean creates an arraylist of statements,and each statements
    created in the application has putted into arraylist.
    At the end a queryManager loads the arraylist from the first bean,
    reads it and executes the statements in a transaction.
    The question is transaction doesn't work, commit and rollback doens't
    work.
    For better understanding the problem i've tried to create a prepared
    statement directly from query manager and using transaction and it
    works!!
    Commit and rollback works correctly!
    Why if i try to load an arraylist of statements stored in another bean
    transaction doesn't work?
    I'm crazying, please help me...
    Can you say me another method to collect prepared statements and use it
    into a transaction?
     
    gbattine, Nov 10, 2006
    #1
    1. Advertising

  2. gbattine

    Lew Guest

    gbattine wrote:
    ....
    > The first bean creates an arraylist of statements,and each statements
    > created in the application has putted into arraylist.


    Perhaps you should make a List of some entity object type or value object
    type, so that you don't yet incur the overhead of making PreparedStatements.

    > At the end a queryManager loads the arraylist from the first bean,
    > reads it and executes the statements in a transaction.
    > ...
    > Why if i try to load an arraylist of statements stored in another bean
    > transaction doesn't work?
    > ...
    > Can you say me another method to collect prepared statements and use it
    > into a transaction?


    At transaction time, open the transaction, use a single PreparedStatement
    iteratively through the List, use its setParameter() methods inside the loop body.

    Using the same PreparedStatement buys you some of the putative efficiency of
    preparing statements. YMMV.

    If the loop excepts or breaks abnormally, issue a rollback; if the loop
    terminates nicely issue a commit.

    In finally {} outside the loop, release any loose resources.

    - Lew
     
    Lew, Nov 11, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eitan

    Error in OLEDB Transaction

    Eitan, Apr 6, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    1,995
    Tad Marshall
    Apr 10, 2005
  2. Eitan

    long time transaction

    Eitan, Apr 11, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    599
    Eitan
    Apr 11, 2005
  3. ben cohen
    Replies:
    0
    Views:
    1,115
    ben cohen
    Aug 20, 2003
  4. R Paley
    Replies:
    2
    Views:
    518
    Paul Uiterlinden
    Nov 20, 2004
  5. Vencz Istv?n
    Replies:
    2
    Views:
    304
Loading...

Share This Page