Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2006

Tip: Looking for answers? Try searching our database.

Transaction...

Thread view: 
gbattine - 10 Nov 2006 09:29 GMT
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?
Lew - 11 Nov 2006 22:44 GMT
...
> 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.
[quoted text clipped - 4 lines]
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.