db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sisilla <sisill...@gmail.com>
Subject Re: Single Transaction Using Multiple Method Calls That Open New Database Connections
Date Thu, 15 Feb 2007 17:24:21 GMT

Thank you very much, David. I appreciate your time and consideration. I chose
to use one Connection Object and pass it to all my methods so no new
connections were opened. It makes my code messier, but I don't know anything
about JTA. Again, thanks for the suggestion. ~Sisilla


David Van Couvering-2 wrote:
> 
> If you're using multiple connections, then you need to use JTA to have 
> it work in a single transaction, and your database driver needs to 
> support XA.
> 
> If you're running in a J2EE environment with declarative transaction 
> management enabled, you're good to go.
> 
> If you're running in a web container, you may be able to get a reference 
> to a UserTransaction object through JNDI (look up UserTransaction in 
> Google).  Some web containers provide JTA support, others don't and 
> you'll need to get it from a third party.
> 
> Others may provide details and/or corrections to what I say here, but 
> that's the general idea.
> 
> David
> 
> Sisilla wrote:
>> Hello All,
>> 
>> I would like to update several tables in one transaction. The updates
>> happen
>> via several method calls, and each of these methods open new database
>> connections. The methods also contain calls to other methods that open
>> new
>> database connections. Is it at all possible that these updates could be
>> handled as a single transaction without eliminating these method calls? 
>> 
>> I am using 
>>                     conn.setAutoCommit(false);
>> before the updates and
>>                     conn.commit();
>> after the updates, but it isn't working as is.
>> 
>> I am using Derby 10.2.1.6 and JDK 1.6.0 on Windows XP Professional. I
>> appreciate any help. 
>> 
>> Thanks,
>> Sisilla
> 
> 

-- 
View this message in context: http://www.nabble.com/Single-Transaction-Using-Multiple-Method-Calls-That-Open-New-Database-Connections-tf3228984.html#a8989769
Sent from the Apache Derby Users mailing list archive at Nabble.com.


Mime
View raw message