J2EE JTA和数据库的transaction研究

王朝java/jsp·作者佚名  2006-01-08
宽屏版  字体: |||超大  

研究有结果了,以下是我做了一些测试得出的结论(Sybase+Weblogic+Tx Data Source):

方法一:

1、设置方法为Container-Tracnsaction,方法的trans-attribute为Required

2、几个方法调用的SP创建前先set chained on,同时SP里是可以使用Tracnsaction的

3、此方法调用的几个方法使用同一Connection,Connection的setAutoCommitCommit使用默认设置或设为false,

若设为true,则抛出异常:Cannot set auto commit to "true" when in distributed transaction

方法二:

1、设置方法为Container-Tracnsaction,方法的trans-attribute为Required

2、几个方法调用的SP创建前先set chained on,同时SP里是可以使用Tracnsaction的

3、此方法调用的几个方法使用各自的Connection,各方法Connection的setAutoCommitCommit使用默认设置;

若设为true,则抛出异常:Cannot set auto commit to "true" when in distributed transaction;

若某方法设为false,同时在EJB的方法描述里把此方法的设置方法为Container-Tracnsaction,方法的trans-attribute

为Required, 则执行到此方法时会抛出异常:SET CHAINED command not allowed within multi-statement transaction.

方法三:

1、设置方法为Container-Tracnsaction,方法的trans-attribute为Required

2、同时各方法为Container-Tracnsaction,方法的trans-attribute为Required

3、几个方法调用的SP创建前先set chained on,同时SP里是可以使用Tracnsaction的

4、此方法调用的几个方法使用各自的Connection,各方法Connection的setAutoCommitCommit使用默认设置;

若设为true,则抛出异常:Cannot set auto commit to "true" when in distributed transaction;

若设为false,抛出异常:SET CHAINED command not allowed within multi-statement transaction.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有