3 Replies Latest reply on Feb 24, 2006 2:13 AM by starksm64

    How to Declaratively set autoCommit to false

    ritukedia

      I am using non-transactional DataSource. I want to declaratively set autoCommit to false in the ds.xml on Jboss 3.2.x.

      My mssql-ds.xml is defined as bleow:

      <datasources>
       <no-tx-datasource>
       <jndi-name>DefaultDS</jndi-name>
       <connection-url>jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mydb;SelectMethod=Cursor</connection-url>
       <driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class>
       <user-name>sa</user-name>
       <password>sa</password>
       <max-pool-size>50</max-pool-size>
       </no-tx-datasource>
      </datasources>


      Currently I am programmatically setting autocommit to false on my connection. Is there a way to set it declaratively in the above ds.xml file?



        • 1. Re: How to Declaratively set autoCommit to false

          There is no current way to do this.

          JBoss assumes auto commit is true when the connection is first created,
          as per spec.
          Maybe you could provide a patch, with code similar to the transaction isolation
          override?

          1 of 1 people found this helpful
          • 2. Re: How to Declaratively set autoCommit to false
            joergvf

             

            "adrian@jboss.org" wrote:

            JBoss assumes auto commit is true when the connection is first created,
            as per spec.
            I searched the JCA and J2EE specs for this, but couldn't find anything backing this assumption. Do you per chance have some concrete reference for this?

            Thanks,
            Jörg

            • 3. Re: How to Declaratively set autoCommit to false
              starksm64



              15.5.3.1 Auto Commit
              When a Connection is in an auto-commit mode, an Interaction, associated with the Connection, automatically commits after it has been executed. The auto-commit mode must be turned off if multiple interactions have to be grouped in a single transaction and committed or rolled back as a unit.
              CCI does not provide explicit set/getAutoCommit methods in the Connection interface. This simplifies the application programming model for the transaction management.
              A resource adapter must manage the auto-commit mode as follows:
              A transactional resource adapter either at the XATransaction or
              LocalTransaction level must set the auto-commit mode of Connection
              instances participating in a transaction to off within the transaction. This
              requirement holds for true both container-managed and bean-managed
              transaction demarcation.
              A transactional resource adapter must set the auto-commit mode of Connection instances to on when used outside a transaction.
              These requirements are independent of whether a transaction is managed as a local or XA transaction. A transactional resource adapter should implement this requirement in an implementation-specific manner.
              A non-transactional resource adapter at the NoTransaction level, is not required to support the auto-commit mode for Connection.