7 Replies Latest reply on Dec 11, 2006 6:35 PM by germanoc

    Datasources and Vanatec JDO

    germanoc

      Hi!

      I'm trying to connect an application to an Oracle DataBase 10g, using a Datasource. The persistence layer was implemented with Vanactec JDO (4.0.2).

      Right now the app uses only local transactions, so the datasource ar not XA. When we connect to the database directly using jdo without the datasource it works fine. We also have tested the Datasource with a normal jdbc app and the work fine too.

      The problem comes when we configure JDO to connect with Datasources, the applications raises the next SQLException:

      /**********************************************/
      javax.jdo.JDODataStoreException: java.sql.SQLException: You cannot commit with autocommit set!
      /**********************************************/

      /*************************************/
      NestedThrowablesStackTrace:
      java.sql.SQLException: You cannot commit with autocommit set!
      at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.jdbcCommit(BaseWrapperManagedConnection.java

      at org.jboss.resource.adapter.jdbc.WrappedConnection.commit(WrappedConnection.java:334)
      at com.versant.core.jdbc.JdbcStorageManagerFactory.init(JdbcStorageManagerFactory.java:186)
      /********************************/


      The same application works fine in OC4, uisnig datasources.
      I have talk about the problem with the support team of vanatec, they told us: "Vanacted need explicit transaction boundary, because of that it is not allowed to use any connection with autocommit=true. Please disable autocommit at your datasource."

      How can we disable autocommit in our datasource??

      Thanks for your help..
      German

        • 1. Re: Datasources and Vanatec JDO
          weston.price

          More like as not your *-ds.xml file is not setup correctly. Can you please post it here?

          • 2. Re: Datasources and Vanatec JDO
            germanoc


            <local-tx-datasource>
            <jndi-name>jdbc/OracleSirDSLocal</jndi-name>
            <connection-url>jdbc:oracle:thin:@mymachine:1521:asdb</connection-url>
            <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
            <user-name>myuser</user-name>
            mypass

            <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>

            <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->

            <type-mapping>Oracle9i</type-mapping>

            </local-tx-datasource>

            • 3. Re: Datasources and Vanatec JDO
              germanoc

              /*************/

              <local-tx-datasource>
              <jndi-name>jdbc/OracleSirDSLocal</jndi-name>
              <connection-url>jdbc:oracle:thin:@aaa:1521:asdb</connection-url>
              <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
              <user-name>a</user-name>
              a

              <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>

              <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->

              <type-mapping>Oracle9i</type-mapping>

              </local-tx-datasource>


              /*************/

              I've tested the datasource with another simple jdbc applictaion and works fine.

              • 4. Re: Datasources and Vanatec JDO
                weston.price

                The issue is the JCA specification which states that all statements outside of a transaction must occur with autocommit set to true. I would guess that you are attempting to execute this code outside of a Local or XA transaction and that as a result the underlying connection is set to autocommit == true which is causing the issue when Vanacted attempts to commit against the underlying resource. In other words, the transaction demarcation is not being appropriately started/terminated.

                In what context are you executing your code?

                • 5. Re: Datasources and Vanatec JDO
                  germanoc

                  The exception ocurrs when trying to initialize the JDO Persistent Manager, don't know what exactly jdo does. It uses two datasources, one for normal operations, and one to manage id's and other stuff.

                  /*************
                  I would guess that you are attempting to execute this code outside of a Local or XA transaction and that as a result the underlying connection is set to autocommit == true
                  *****************/
                  Yoú're right. Vanatec told me that they contol the transaction, so they need the conection to be autocommit=false.

                  Is any property o configuration to make explicit in the datasource to set autocommit in false?

                  thanx

                  • 6. Re: Datasources and Vanatec JDO
                    weston.price

                    No as this would be in violation of the JCA specification. The only way that this would happen is if you began a JTA transaction prior to the initialization of the Vantac persistence manager. This would put the connection in the correct state for Vantec to use. However, the idea of Vantec *controlling* the transaction would worry me as this is usually not the role of an ORM running within the context of an application server. ORM's typically provide transaction demarcation in 2 tier environments but delegate this functionality to the underlying application server/user transaction scenarios in an enterprise environment and simply become a participant.

                    Also, it looks as if you asked the same question here:

                    http://www.vanatec.com/en/community-support/forum/discussions/view_topic?topic_id=4401&topic_offset=0

                    and Vanatec seems to suggest that they will work with JCA however if they are indeed modifying the transaction state of the underlying connection (doing commit/rollback) this would not be the case as this is the role of JCA, not Vantec.

                    Again, I could be in error on this being that I do not know Vantec or their API, but something sounds sketchy.

                    • 7. Re: Datasources and Vanatec JDO
                      germanoc

                      Thanks