Article View: borland.public.jbuilder.java.api
Article #155Re: Distributed transactions?
From: Tad Frysinger
Date: Mon, 14 Jun 2004 16:29
Date: Mon, 14 Jun 2004 16:29
39 lines
2505 bytes
2505 bytes
Scott wrote: > Hi, > > We are writing a web application in Cold Fusion. > > But in a few places it looks like the app will need to write data to at > least two different databases and maintain transaction integrity. > > CF runs as a J2EE application so we are evaluating tapping into the > underlying JVM to do these critical database writes. > > Is it possible using JDBC to manage transactions this way? Would it be > enough to open the two connections I need (turning auto commit off), issue > my two statements and if either fails, rollback both transactions (or commit > if there are no errors)? > > Or do we need to look to JTA for distributed transactions? > > Any advice appreciated. > > Thanks > Scott > > I don't think you are going to want to go down the "issue two statements " route. What happens if statement A succeeds in the commit but statement B doesn't? You will have to manually roll back, which is doable but a pain in the butt. You really need to coordinate the two statements. JTA is exactly what does this - you do need to make sure that the various pieces are "JTA aware". But then you separate out your transaction logic separate from the data access. Transaction begin..end..commit is handled entirely within JTA. The actual objects that do the data updates can create Connection objects, etc. and even close them - JTA takes care of rolling back the entire thing for you if necessary. -- Tad Frysinger [TeamB]
Technical Details
Message-ID:
<40cdd28a$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<40ccdb5d@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,55bcad8bab85c179 X-Google-Attributes: gid1089d0,public Date: Mon, 14 Jun 2004 10:29:48 -0600 From: Tad Frysinger <tfrysinger@earthlink.net> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.jbuilder.java.api Subject: Re: Distributed transactions? References: <40ccdb5d@newsgroups.borland.com> In-Reply-To: <40ccdb5d@newsgroups.borland.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 64.58.30.72 Message-ID: <40cdd28a$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1087230602 64.58.30.72 (14 Jun 2004 09:30:02 -0700) Lines: 40 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail