1 Reply Latest reply on Mar 20, 2004 8:53 AM by Adrian Brock

    You cannot set autocommit during a managed transaction!! Why

    jww_xj Newbie

      I'm use sqlserver xa datasource,but an exception is thrown when i perform attenpt to con.setAutocommit(false);
      my trace:

      16:14:58,093 INFO [STDOUT] statement:: update XXXX set status = '1' where XXXX='XXXX'
      16:14:58,093 INFO [STDOUT] statement:: update XXXX set status = '1' where XXXX='XXXX'
      16:14:58,093 INFO [STDOUT] getConnection()->retrieve JDBC Connection java:/DataSource
      16:14:58,140 INFO [STDOUT] con ::org.jboss.resource.adapter.jdbc.WrappedConnection@a00fd
      16:14:58,140 INFO [STDOUT] java.sql.SQLException: You cannot se
      t autocommit during a managed transaction!
      16:14:58,156 INFO [STDOUT] rollback!
      16:14:58,156 INFO [STDOUT] rollback SQLException!
      16:14:58,156 ERROR [STDERR] java.sql.SQLException: You cannot rollback during a managed transaction!
      16:14:58,156 ERROR [STDERR] at org.jboss.resource.adapter.jdbc.BaseWrapperMa
      nagedConnection.jdbcRollback(BaseWrapperManagedConnection.java:508)
      16:14:58,156 ERROR [STDERR] at org.jboss.resource.adapter.jdbc.WrappedConnec
      tion.rollback(WrappedConnection.java:477)
      


      my xa datasource :
      <datasources>
       <xa-datasource>
       <jndi-name>DataSource</jndi-name>
       <xa-datasource-class>com.microsoft.jdbcx.sqlserver.SQLServerDataSource</xa-datasource-class>
       <xa-datasource-property name="ServerName">localhost</xa-datasource-property>
       <xa-datasource-property name="DatabaseName">XXX</xa-datasource-property>
       <xa-datasource-property name="SelectMethod">cursor</xa-datasource-property>
      <!-- not sure if these should be here-->
       <user-name>XXX</user-name>
       <password>XXX</password>
       </xa-datasource>
      
      </datasources>
      
      


      my code as follow:
       InitialContext jndiCtx;
       jndiCtx = new InitialContext();
       Connection con = (DataSource)jndiCtx.lookup(XXX);
       con.getConnection();
       con.setAutoCommit(false);
      
      


      pls help me!
      thanks!