5 Replies Latest reply on Jul 4, 2002 12:37 PM by dpiemonte

    Commiting transaction on timeout/shutdown

    ushankar

      Hi,

      I am using bean managed transactions using JTA APIs. When I set a transaction timeout and if the timeout expires, then the transaction gets committed. Is there some place where I can specify not to commit the transaction, but to do a rollback on transaction timeout.

      The same thing happens when JBOSS is shut down. If there is an open transaction, it gets committed. Can I specify some where that the transaction is to be rolled back on shutdown or timeout?

      Thanks for any help.

      Regards,
      Shankar

        • 1. Re: Commiting transaction on timeout/shutdown
          davidjencks

          It's always polite to indicate what version of jboss you are using. It's even more polite to include a junit test case or at least some simple sample code demonstrating the problem.

          When you say "JTA API" do you mean you are using UserTransaction?

          Are you sure youre datasource isn't somehow set to autocommit?

          • 2. Re: Commiting transaction on timeout/shutdown
            ushankar

            Sorry about that. The JBOSS version I am using is Jboss-2.4.3. I am using this along with Oracle 8.1.7. Yes. I am using UserTransaction API for beginning and committing a transaction. I will greatly appreciate if you can tell me how one would turn Autocommit to off in data source.

            Regards,
            Shankar

            • 3. Re: Commiting transaction on timeout/shutdown
              davidjencks

              If you use XADataSourceLoader with XADataSourceImpl autocommit is automatically set off. If you use JDBCDataSourceLoader autocommit is on, and you can't use the transaction manager through UserTransaction to control transactions.

              • 4. Re: Commiting transaction on timeout/shutdown
                ushankar

                I am using XADataSourceLoader.


                OracleDS
                org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl

                jdbc:oracle:thin:@pc-22.3mts.com:1521:bdnalocl
                bizdna
                bizdna


                and the transaction settings are,


                100
                oracle.jdbc.xa.OracleXid


                When I leave a transaction open and shutdown jboss, the corresponding data gets committed.

                • 5. Re: Commiting transaction on timeout/shutdown
                  dpiemonte

                  Hi,
                  I 'm having the same problem. I can not solve it, in fact, if you use Oracle JDBC driver, I think there is no solution at all. In Oracle documentation: "JDBC Developer's Guide and Reference Release 2" (http://otn.oracle.com/tech/java/sqlj_jdbc/content.html) you can read the following note:

                  "If auto-commit mode is disabled and you close the connection without explicitly committing or rolling back your last changes, then an implicit COMMIT operation is executed."

                  I 'm quite sure that this behaviour does not respect JDBC specification, but it is in the documentation.

                  I don't know how exactly JBoss manage connections when it shuts down or time up occurs, but if it directly closes open connections, an automatic commit is performed.

                  By the way I'll appreciate if somebody can tell what exactly JBoss does with open connections when it shuts down or time up occurs. There are no roll backs, aren't there??

                  thank you, I hope this help.