title: Solution for java.sql.SQLException: could not use local transaction commit in a global transaction
body: <p>I'm running a J2EE MDB in a Weblogic 10.3 clustered environment. </p>
  
  <p>Within one of the methods in the code I create a JDBC connection and turn off auto commit. The connection to the database is made through a XA enabled Data source. The reason for turning the auto-commit off is because I'm using a temp table. </p>
  
  <p>When I'm done with the temp table &amp; other SQL queries I commit the Transaction and turn auto-commit back on. For the most part this has not been a problem but I received the following exception when executing the method, the exception occurred on the line in the code where I issue the commit.</p>
  
  <p>Not sure why I received as in the method I only make calls to a single database, I wonder if its because the data source is XA enabled? Any insight as to why this exception occurs and why it only occurs sometimes would be greatly appreciated</p>
  
  <pre><code>java.sql.SQLException: could not use local transaction commit in a global transaction
      at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
      at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:112)
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:173)
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:229)
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:403)
      at oracle.jdbc.driver.PhysicalConnection.disallowGlobalTxnMode(PhysicalConnection.java:6139)
      at oracle.jdbc.driver.PhysicalConnection.commit(PhysicalConnection.java:3320)
      at oracle.jdbc.driver.PhysicalConnection.commit(PhysicalConnection.java:3357)
      at oracle.jdbc.OracleConnectionWrapper.commit(OracleConnectionWrapper.java:130)
      at weblogic.jdbc.wrapper.XAConnection.commit(XAConnection.java:844)
      at weblogic.jdbc.wrapper.JTAConnection.commit(JTAConnection.java:326)
      at com.myPackage.myApp.myDBCaller.tempTableMethod(myDBCaller.java:390)
      at com.myPackage.myApp.myDBCaller.start(myDBCaller.java:153)
      at com.myPackage.myApp.myDBCaller.onMessage(myDBCaller.java:117)
      at sun.reflect.GeneratedMethodAccessor1683.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
      at java.lang.reflect.Method.invoke(Method.java:599)
      at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:281)
      at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:187)
      at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:154)
      at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:126)
      at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:114)
      at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
      at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
      at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
      at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:126)
      at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:114)
      at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
      at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:210)
      at $Proxy228.onMessage(Unknown Source)
      at weblogic.ejb.container.internal.MDListener.execute(MDListener.java:518)
      at weblogic.ejb.container.internal.MDListener.transactionalOnMessage(MDListener.java:423)
      at weblogic.ejb.container.internal.MDListener.onMessage(MDListener.java:325)
      at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:4547)
      at weblogic.jms.client.JMSSession.execute(JMSSession.java:4233)
      at weblogic.jms.client.JMSSession.executeMessage(JMSSession.java:3709)
      at weblogic.jms.client.JMSSession.access$000(JMSSession.java:114)
      at weblogic.jms.client.JMSSession$UseForRunnable.run(JMSSession.java:5058)
      at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:516)
      at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
      at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
  </code></pre>