0 Replies Latest reply on Feb 18, 2006 10:30 AM by cagean

    distributed transactions

    cagean

      the disadvantage that we have is that the transaction this not doing neither commit, nor rollback, nor displays exceptions. the states of the transaction are 0 after initiates and 6 after the commit and rollback. when we see in the data bases non entrance the data even though does not appear any exception. the data bases that we used are postgreSQL, and the server is JBoss 4.0.2

      public void insertIntoVertical(VOInsert voi, String schemaId, Vector fragments, SiteFragment siteFragment, UserTransaction ut) throws Exception
      {
      PGXADataSource xads = null;
      Connection conPostgres = null;
      VOSite vos = null;
      Vector fields = null;
      Statement s = null;
      String insertString;

      try

      {

      ut.begin();
      for(int i = 0; i < fragments.size(); i++) /*this is a Vector with VOFragment which contains information about an specific fragment*/
      {
      VOFragment vof= (VOFragment)fragments.get(i);
      vos = siteFragment.getSite(vof.getSite());
      xads = new PGXADataSource();
      xads.setDatabaseName(vos.getDbName());
      xads.setPortNumber(vos.getPort());
      xads.setServerName(vos.getUrl());
      xads.setPassword(vos.getPassword());
      xads.setUser(vos.getUserName());

      conPostgres = xads.getConnection();
      conPostgres.setAutoCommit(false);
      s = conPostgres.createStatement();

      fields = siteFragment.getFragmentFields(vos.getName(),vof.getName());
      insertString = createInsertString(fields,voi,vof.getName());
      //these two methods create the strings to insert in each one fragments

      s.executeUpdate(insertString);
      }

      ut.commit();
      }
      catch(Exception e)
      {
      ut.rollback();
      e.printStackTrace();
      }
      }