2 Replies Latest reply on Aug 14, 2006 8:56 PM by avanikamal

    JBoss 4.0.2 - You cannot set autocommit during a managed tra

    andytsoy

      Dear all,

      JBoss 4.0.2 + JBoss Portal + Oracle

      When I use JBoss Portal (localhost:8080/portal) to call my portlet to do some database access in my JAVA class, it will connect to Oracle database and run the statement ?connection.setAutoCommit(false)?( Because I may need rollback). When I call this statement, there is an error occur as the following:

      *******************************************************************************
      java.sql.SQLException: You cannot set autocommit during a managed transaction!
      at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.setJdbcAutoCommit(BaseWrapperManagedConnection.java:462)

      at org.jboss.resource.adapter.jdbc.WrappedConnection.setAutoCommit(WrappedConnection.java:432)

      *******************************************************************************

      Could any one help to suggest some solution?

      If you want to get more detail. Please ask me ! Thank you!

      Remarks: In JBoss, I have oracle-xa-ds.xml in the deploy folder for setting of oracle.

        • 1. Re: JBoss 4.0.2 - You cannot set autocommit during a managed
          marklittle

          Sounds to me like your database connection has been obtained from an XADatasource and is enlisted within a transaction managed by JBoss. In which case, you aren't allowed to change the autocommit flag (it has to remain as false) and the transaction manager will commit or rollback on your behalf. If you don't have visibility of this db connection in your code, then it may be an idea to ask the Portlet guys.

          Mark.

          • 2. Re: JBoss 4.0.2 - You cannot set autocommit during a managed
            avanikamal

            The Spec says that "Attempting to enable autoCommit by calling connection.setAutoCommit() with a value of true will throw an SQLException."

            Why does JBoss throw SQLException when setAutoCommit(false) is called?

            Thanks.
            Kamal