4 Replies Latest reply on Apr 16, 2006 11:26 AM by xiaoqj

    ArjunaTS and MS SQL server 2000

    xiaoqj

      I was trying to run the sample code in com.arjuna.demo.jta.jdbcbank, in which the XADataSource registered into JNDI shields all the dbms vendor specific informations.

      The following code do the configuration

      SQLServerDataSource ds = new
      com.microsoft.jdbcx.sqlserver.SQLServerDataSource();
      ds.setDescription("MSSQLServer2k DataSource");
      ds.setServerName(host);
      ds.setPortNumber(1433);
      ds.setDatabaseName(dbName);
      ds.setSelectMethod("cursor"); // it seems a MUST listed in MS JDBC driver user guide

      As in the example, a JNDI implementation of fscontext from sun, is used, which should be error-free.

      But, the follwing exception is thrown:
      java.sql.SQLException: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Failed to initialize DTC. Check if DTC service is running.

      It seems strange. Is the Distributed Transaction Coordinator Service which is provided by microsoft really a neccessity, which kicks out other TM vendor.

        • 1. Re: ArjunaTS and MS SQL server 2000
          marklittle

          Even though you are using JBoss Transactions to manage two-phase (and possibly distributed) transactions amongst SQLServer instances, you still need to ensure that the SQLServer instance is capable of participating in the two-phase commit protocol. SQLServer accomplishes this by leveraging the DTC (essentially the DTC becomes the RM).

          To do this, check http://msdn2.microsoft.com/en-US/library/ms378931.aspx for a start and read the xa_install.txt file that ships with the driver.

          Let me know if this sorts things out for you.

          Mark.

          • 2. Re: ArjunaTS and MS SQL server 2000
            xiaoqj

            That tutorial page helps a lot. 3x

            The way that DTC and JBossTS inteoperate seems like another example of interposition.

            Some suggestions about the com.arjuna.demo.jta.jdbcbank example:

            1. the sql sentence in the "create_account()" method is wrong, where column name "accountName" should be corrected to "name"

            2. the create_table() method is called every time the Bank is created, which is not suitable. For here the Bank object has a persistent backend storage. unlike the com.arjuna.demo.jta.localbank example. So rename the create_table() to create_table_if_not_exists(). The following code can do the judgement.

            private boolean exists(Connection conn, String tableName) {
            if (conn == null)
            return false;

            DatabaseMetaData md = null;
            ResultSet rs = null;

            try {
            md = conn.getMetaData();
            rs = md.getTables(null, null, "%", null);
            while (rs.next()) {
            String name = rs.getString(3);
            if (name.equalsIgnoreCase(tableName))
            return true;
            }
            } catch (Exception e) {
            e.printStackTrace();
            } finally {
            if(rs != null)
            try {
            rs.close();
            } catch (SQLException e) {
            e.printStackTrace();
            }
            }

            return false;
            }

            3. The Bank class acts as a facade to the back-end storage. Probably the tx.begin, tx.commit clauses should be put in Bank for explicitly tx demarcation, rather than in BankClient. If the user would like to do transfer across different banks, nested tx shall be introduced.

            • 3. Re: ArjunaTS and MS SQL server 2000
              marklittle

              You're right in that this is like interposition, with DTC acting as a subordinate coordinator.

              We'll take a look at the suggestions on improvements (though nested transactions won't work here because we need this to run on databases that don't support them). However, I've registered an issue in JIRA (http://jira.jboss.com/jira/browse/JBTM-58) should you wish to track this.

              Can you just confirm that you have now got the example running?

              • 4. Re: ArjunaTS and MS SQL server 2000
                xiaoqj

                3x u for help. My pleasure to do some contribution.