oracle 使用 JDBC 提交事务时出错 - 在全局事务期间不允许操作 Connection.commit
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20036080/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error committing transaction using JDBC - Operation Connection.commit is not allowed during a global transaction
提问by user2988422
Am getting the following error when am trying to commit transaction using jdbc from a local ejb connection.commit(); Oracle database
当我尝试使用 jdbc 从本地 ejb connection.commit() 提交事务时收到以下错误;甲骨文数据库
java.sql.SQLException: DSRA9350E: Operation Connection.commit is not allowed during a global transaction. [17/11/13 15:33:00:621 EST] 00000029 SystemErr R at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.commit(WSJdbcConnection.java:941) [17/11/13 15:33:00:621 EST] 00000029 SystemErr R at com.bmo.olbb.mostvisitedcount.ejb.MergeAuditRecordsBean.startOperation(MergeAuditRecordsBean.java:89) [17/11/13 15:33:00:621 EST] 00000029 SystemErr R at com.bmo.olbb.mostvisitedcount.ejb.MergeAuditRecordsBean.updatePageCountValues(MergeAuditRecordsBean.java:21) [17/11/13 15:33:00:621 EST] 00000029 SystemErr R at com.bmo.olbb.mostvisitedcount.ejb.EJSLocal0SLMergeAuditRecordsBean_9da6c3b0.updatePageCountValues(EJSLocal0SLMergeAuditRecordsBean_9da6c3b0.java) [17/11/13 15:33:00:621 EST] 00000029 SystemErr R at com.bmo.ctp.test.testEJBservlet.doGet(testEJBservlet.java:51) [17/11/13 15:33:00:621 EST] 00000029 SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:743) [17/11/13 15:33:00:621 EST] 00000029 SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) [17/11/13 15:33:00:621 EST] 00000029 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1103) [17/11/13 15:33:00:621 EST] 00000029 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:570) [17/11/13 15:33:00:621 EST] 00000029 SystemErr R at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:486) [17/11/13 15:33:00:621 EST] 00000029 SystemErr R at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3440) [17/11/13 15:33:00:621 EST] 00000029 SystemErr R at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:267) [17/11/13 15:33:00:621 EST] 00000029 SystemErr R at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:815) [17/11/13 15:33:00:621 EST] 00000029 SystemErr R at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1461) [17/11/13 15:33:00:621 EST] 00000029 SystemErr R at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:118) [17/11/13 15:33:00:621 EST] 00000029 SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:458) [17/11/13 15:33:00:621 EST] 00000029 SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:387) [17/11/13 15:33:00:621 EST] 00000029 SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:267) [17/11/13 15:33:00:621 EST] 00000029 SystemErr R at com.ibm.ws.ssl.channel.impl.SSLConnectionLink.determineNextChannel(SSLConnectionLink.java:1037) [17/11/13 15:33:00:621 EST] 00000029 SystemErr R at com.ibm.ws.ssl.channel.impl.SSLConnectionLink$MyReadCompletedCallback.complete(SSLConnectionLink.java:644) [17/11/13 15:33:00:621 EST] 00000029 SystemErr R at com.ibm.ws.ssl.channel.impl.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1818) [17/11/13 15:33:00:621 EST] 00000029 SystemErr R at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165) [17/11/13 15:33:00:621 EST] 00000029 SystemErr R at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217) [17/11/13 15:33:00:621 EST] 00000029 SystemErr R at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161) [17/11/13 15:33:00:621 EST] 00000029 SystemErr R at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136) [17/11/13 15:33:00:621 EST] 00000029 SystemErr R at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:195) [17/11/13 15:33:00:621 EST] 00000029 SystemErr R at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:743) [17/11/13 15:33:00:621 EST] 00000029 SystemErr R at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:873) [17/11/13 15:33:00:621 EST] 00000029 SystemErr R at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1473)
java.sql.SQLException:DSRA9350E:在全局事务期间不允许操作 Connection.commit。[17/11/13 15:33:00:621 EST] 00000029 SystemErr R at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.commit(WSJdbcConnection.java:941) [17/11/13 15:33:00 :621 EST] 00000029 SystemErr R at com.bmo.olbb.mostvisitedcount.ejb.MergeAuditRecordsBean.startOperation(MergeAuditRecordsBean.java:89) [17/11/13 15:33:00:621 EST00r200rmo] R .olbb.mostvisitedcount.ejb.MergeAuditRecordsBean.updatePageCountValues(MergeAuditRecordsBean.java:21) [17/11/13 15:33:00:621 EST] 00000029 SystemErr R 位于 com.bmo.olbb.jb.ejb.updateBange.s. EJSLocal0SLMergeAuditRecordsBean_9da6c3b0.java) [17/11/13 15:33:00:621 EST] 00000029 SystemErr R at com.bmo.ctp.test。
回答by rushabhkumar khandare
In XA-Datasources->WebSphere Application Server data source properties->WebSphere Application Server data source properties->click Non-transactional data source as True.
在 XA-Datasources->WebSphere Application Server 数据源属性->WebSphere Application Server 数据源属性->单击非事务性数据源为 True。
回答by Mark Rotteveel
Your application is probably using a Container-Managed Transaction or another kind of managed connection. When using managed transactions you are not allowed to commit()
yourself, as that is handled by the application container (maybe even using a distributed transaction if you are using multiple datasources).
您的应用程序可能正在使用容器管理事务或其他类型的托管连接。使用托管事务时,您commit()
不能自己使用,因为这是由应用程序容器处理的(如果您使用多个数据源,甚至可能使用分布式事务)。
See Container-Managed Transactionsin the JavaEE 7 tutorial:
请参阅JavaEE 7 教程中的容器管理事务:
Enterprise beans that use container-managed transaction demarcation must not use any transaction-management methods that interfere with the container's transaction demarcation boundaries. Examples of such methods are the
commit
,setAutoCommit
, androllback
methods ofjava.sql.Connection
or thecommit
androllback
methods ofjavax.jms.Session
. If you require control over the transaction demarcation, you must use application-managed transaction demarcation.
使用容器管理事务划分的企业 bean 不得使用任何干扰容器事务划分边界的事务管理方法。这些方法的例子是
commit
,setAutoCommit
,和rollback
的方法java.sql.Connection
或commit
与rollback
方法javax.jms.Session
。如果您需要控制事务划分,则必须使用应用程序管理的事务划分。
A commit()
is done automatically if the method (or chain of methods) completes without an Exception
(unless an explicit rollback is requested on the context).
commit()
如果方法(或方法链)在没有 a 的情况下完成Exception
(除非在上下文中请求显式回滚),则A将自动完成。
回答by Ricardo Sarto
One time I had de same problem. At that time I was using EJB 1.0 and the problem was happening because I did not map the EJB method in Container Transaction Section inside the ejb-jar.xml
有一次我遇到了同样的问题。当时我正在使用 EJB 1.0 并且问题发生了,因为我没有在 ejb-jar.xml 中映射容器事务部分中的 EJB 方法
回答by JitenS
Navigate to Resources > JDBC > JDBC providers > JDBC_provider > Data sources > data_source > WebSphere Application Server data source properties
Check Non-transactional data source property.
导航到资源 > JDBC > JDBC 提供程序 > JDBC_provider > 数据源 > data_source > WebSphere Application Server 数据源属性
检查非事务性数据源属性。