研究有结果了,以下是我做了一些测试得出的结论(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.
本文探讨了在Sybase+Weblogic环境下,使用J2EE JTA进行数据库事务管理的三种方法。方法一和方法二涉及在同一连接或不同连接下设置chained on,并在存储过程中使用事务。所有方法在分布式事务中禁止设置auto commit为true。方法三中,所有方法都设置为Container-Transaction,但在多语句事务中不允许使用SET CHAINED命令。
2848

被折叠的 条评论
为什么被折叠?



