コード例 #1
0
ファイル: Ejer12.java プロジェクト: kalamar23/Ejercicios
  // Sucecion de Fibonacci
  static void suce() {
    int numero, a = 1, b = 0, c;
    StringBuffer sb = new StringBuffer();
    String s1 =
        JOptionPane.showInputDialog("Ingrese el numero hasta el que desea ver la sucesion : ");
    numero = Integer.parseInt(s1);
    while (a < numero) {
      a += b;
      sb.append(a + " , ");
      b += a;
      sb.append(b + " , ");
    }

    JOptionPane.showMessageDialog(null, "Fibonacci = " + sb);

    int numero2 =
        JOptionPane.showOptionDialog(
            null,
            "Seleccione",
            "Escoja",
            JOptionPane.YES_NO_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE,
            null,
            new Object[] {"Opcion 1", "Opcion 2", "Opcion 3"},
            "Opcion 3");
  }
コード例 #2
0
ファイル: URIArg.java プロジェクト: tedvals/fleetmng
 public String toString() {
   StringBuffer sb = new StringBuffer();
   sb.append(this.key);
   if (this.hasValue()) {
     sb.append("=").append(this.val);
   }
   return sb.toString();
 }
コード例 #3
0
ファイル: uva706.java プロジェクト: de-yu/uva
  public static void main(String[] args) throws IOException {
    Scanner scanner = new Scanner(new BufferedInputStream(System.in));

    int num[][] = {
      {0, 2, 3, 5, 6, 7, 8, 9},
      {2, 3, 4, 5, 6, 8, 9},
      {0, 2, 3, 5, 6, 8, 9},
      {0, 4, 5, 6, 8, 9},
      {0, 1, 2, 3, 4, 7, 8, 9},
      {0, 2, 6, 8},
      {0, 1, 3, 4, 5, 6, 7, 8, 9}
    };

    while (scanner.hasNextInt()) {
      int a = scanner.nextInt();
      String b = scanner.next();
      if (a == 0) break;
      String data[][] = new String[5 + (a - 1) * 2][(3 + (a - 1)) * b.length()];

      for (int i = 0; i < 5 + (a - 1) * 2; i++)
        for (int j = 0; j < (3 + (a - 1)) * b.length(); j++) data[i][j] = " ";

      for (int i = 0; i < b.length(); i++) {
        for (int j = 0; j < 3; j++) {
          for (int k = 0; k < num[j].length; k++) {
            if ((int) b.charAt(i) - 48 == num[j][k]) {
              for (int h = 0; h < a; h++) data[(a + 1) * j][1 + i * (a + 2) + h] = "-";
            }
          }
        }
        for (int j = 3; j < 5; j++) {
          for (int k = 0; k < num[j].length; k++) {
            if ((int) b.charAt(i) - 48 == num[j][k]) {
              for (int h = 0; h < a; h++) data[1 + h][(j - 3) * (a + 1) + (i * (a + 2))] = "|";
            }
          }
        }
        for (int j = 5; j < 7; j++) {
          for (int k = 0; k < num[j].length; k++) {
            if ((int) b.charAt(i) - 48 == num[j][k]) {
              for (int h = 0; h < a; h++) data[a + 2 + h][(j - 5) * (a + 1) + (i * (a + 2))] = "|";
            }
          }
        }
      }
      StringBuffer sb = new StringBuffer("");
      for (int i = 0; i < 5 + (a - 1) * 2; i++) {
        for (int j = 0; j < (3 + (a - 1)) * b.length(); j++) {
          if ((j - (a + 1)) % (a + 2) == 0 && (j + 1) != (3 + (a - 1)) * b.length())
            sb.append(data[i][j] + " ");
          else sb.append(data[i][j]);
        }
        sb.append("\n");
      }
      System.out.println(sb);
    }
  }
コード例 #4
0
ファイル: URIArg.java プロジェクト: colima/OpenDMTP
 public String toString() {
   StringBuffer sb = new StringBuffer();
   sb.append(this.key);
   String v = this.val;
   if ((v != null) && !v.equals("")) {
     sb.append("=").append(v);
   }
   return sb.toString();
 }
コード例 #5
0
ファイル: MDPSim.java プロジェクト: indrajit23/mdp-ip
 public static String PrintList(ArrayList l) {
   StringBuffer sb = new StringBuffer("[ ");
   Iterator i = l.iterator();
   while (i.hasNext()) {
     Double d = (Double) i.next();
     sb.append(MDP._df.format(d.doubleValue()) + " ");
   }
   sb.append("]");
   return sb.toString();
 }
コード例 #6
0
 private String bigIntToHexString(BigInteger bi) {
   StringBuffer buf = new StringBuffer();
   buf.append("0x");
   String val = bi.toString(16);
   for (int i = 0; i < ((2 * addressSize) - val.length()); i++) {
     buf.append('0');
   }
   buf.append(val);
   return buf.toString();
 }
コード例 #7
0
ファイル: URIArg.java プロジェクト: colima/OpenDMTP
 /**
  * ** Returns a String representation of all key/values ** @param sbuff The StringBuffer to write
  * the key/values to, or null ** for a new one ** @return A String representation of all
  * key/values
  */
 public StringBuffer getArgString(StringBuffer sbuff) {
   StringBuffer sb = (sbuff != null) ? sbuff : new StringBuffer();
   for (Iterator i = this.getKeyValList().iterator(); i.hasNext(); ) {
     KeyVal kv = (KeyVal) i.next();
     sb.append(kv.toString());
     if (i.hasNext()) {
       sb.append("&");
     }
   }
   return sb;
 }
コード例 #8
0
ファイル: URIArg.java プロジェクト: tedvals/fleetmng
 /**
  * ** Returns a String representation of all key/values ** @param sbuff The StringBuffer to write
  * the key/values to, or null for a new one ** @param includeBlankValues True to include keys for
  * blank values. ** @return A String representation of all key/values
  */
 public StringBuffer getArgString(StringBuffer sbuff, boolean includeBlankValues) {
   StringBuffer sb = (sbuff != null) ? sbuff : new StringBuffer();
   int argCnt = 0;
   for (Iterator i = this.getKeyValList().iterator(); i.hasNext(); ) {
     KeyVal kv = (KeyVal) i.next();
     if (includeBlankValues || kv.hasValue()) {
       if (argCnt > 0) {
         sb.append("&");
       }
       sb.append(kv.toString());
       argCnt++;
     }
   }
   return sb;
 }
コード例 #9
0
 String concate(String[] strings) {
   StringBuffer buffer = new StringBuffer("");
   for (String string : strings) {
     buffer.append(string);
   }
   return buffer.toString();
 }
コード例 #10
0
ファイル: Elf.java プロジェクト: patronuliviu/Flashtool
  /**
   * @param section
   * @param index
   * @return
   * @throws IOException
   */
  final String getStringFromSection(final Section section, final int index) throws IOException {
    if (index > section.getSize()) {
      return "";
    }

    final StringBuffer str = new StringBuffer();
    // Most string symbols will be less than 50 bytes in size
    final byte[] tmp = new byte[50];

    this.efile.seek(section.getFileOffset() + index);
    while (true) {
      int len = this.efile.read(tmp);
      for (int i = 0; i < len; i++) {
        if (tmp[i] == 0) {
          len = 0;
          break;
        }
        str.append((char) tmp[i]);
      }
      if (len <= 0) {
        break;
      }
    }

    return str.toString();
  }
コード例 #11
0
ファイル: Util.java プロジェクト: gubo/slipwire
 /**
  * @param s
  * @return
  */
 public static String mask(final String s) {
   final StringBuffer buffer = new StringBuffer(25);
   final int count = (s != null ? s.length() : 0);
   for (int n = 0; n < count; n++) {
     buffer.append('*');
   }
   return buffer.toString();
 }
コード例 #12
0
ファイル: URIArg.java プロジェクト: tedvals/fleetmng
 /**
  * ** A String reperesentation of this URI (with arguments) ** @param includeBlankValues True to
  * include keys for blank values. ** @return A String representation of this URI
  */
 public String toString(boolean includeBlankValues) {
   StringBuffer sb = new StringBuffer(this.getURI());
   if (!ListTools.isEmpty(this.getKeyValList())) {
     sb.append("?");
     this.getArgString(sb, includeBlankValues);
   }
   return sb.toString();
 }
コード例 #13
0
ファイル: URIArg.java プロジェクト: colima/OpenDMTP
 /**
  * ** A String reperesentation of this URI (with arguments) ** @return A String representation of
  * this URI
  */
 public String toString() {
   StringBuffer sb = new StringBuffer(this.getURI());
   if (!ListTools.isEmpty(this.getKeyValList())) {
     sb.append("?");
     this.getArgString(sb);
   }
   return sb.toString();
 }
コード例 #14
0
ファイル: StatusCode.java プロジェクト: Eltondcr/opengtsgrey
 public String toString() {
   StringBuffer sb = new StringBuffer();
   sb.append(this.getAccountID());
   sb.append("/");
   sb.append(this.getDeviceID());
   sb.append(" ");
   sb.append(this.getStatusCode());
   sb.append("[");
   sb.append(this.getDescription());
   sb.append("]");
   return sb.toString();
 }
コード例 #15
0
ファイル: Main_1.java プロジェクト: Rahul2025/Thesis
 public String nextString() throws Exception {
   StringBuffer sb = new StringBuffer("");
   byte c = read();
   while (c <= ' ') c = read();
   do {
     sb.append((char) c);
     c = read();
   } while (c > ' ');
   return sb.toString();
 }
コード例 #16
0
ファイル: URIArg.java プロジェクト: tedvals/fleetmng
 /**
  * ** Hex-encodes a URL argument ** @param sb The StringBuffer where the hex encoded String
  * argument will be placed ** @param s The URL argument to encode ** @param obfuscateAll True to
  * force hex-encoding on all argument characters ** @return The StringBuffer where the hex-encoded
  * String will be placed
  */
 public static StringBuffer encodeArg(StringBuffer sb, String s, boolean obfuscateAll) {
   if (sb == null) {
     sb = new StringBuffer();
   }
   if (s != null) {
     char ch[] = new char[s.length()];
     s.getChars(0, s.length(), ch, 0);
     for (int i = 0; i < ch.length; i++) {
       if (obfuscateAll || URIArg.shouldEncodeArgChar(ch[i])) {
         // escape non-alphanumeric characters
         sb.append("%");
         sb.append(Integer.toHexString(0x100 + (ch[i] & 0xFF)).substring(1));
       } else {
         // letters and digits are ok as-is
         sb.append(ch[i]);
       }
     }
   }
   return sb;
 }
コード例 #17
0
ファイル: MGoal.java プロジェクト: WilkerDiaz/Compiere
 /**
  * String Representation
  *
  * @return info
  */
 @Override
 public String toString() {
   StringBuffer sb = new StringBuffer("MGoal[");
   sb.append(get_ID())
       .append("-")
       .append(getName())
       .append(",")
       .append(getGoalPerformance())
       .append("]");
   return sb.toString();
 } //	toString
コード例 #18
0
ファイル: MDPSim.java プロジェクト: indrajit23/mdp-ip
 public static String PrintState(ArrayList state) {
   StringBuffer sb = new StringBuffer();
   Iterator i = state.iterator();
   while (i.hasNext()) {
     Object o = i.next();
     if (o instanceof Boolean) {
       Boolean val = (Boolean) o;
       sb.append((val.booleanValue() ? "." : "X"));
     }
   }
   return sb.toString();
 }
コード例 #19
0
ファイル: DTTemplate.java プロジェクト: agustinf/OpenGTS
 public String toString() {
   StringBuffer sb = new StringBuffer();
   sb.append(this.isHiRes() ? "H" : "L");
   sb.append(FIELD_VALUE_SEPARATOR);
   sb.append(this.getType());
   sb.append(FIELD_VALUE_SEPARATOR);
   sb.append(this.getIndex());
   sb.append(FIELD_VALUE_SEPARATOR);
   sb.append(this.getLength());
   return sb.toString();
 }
コード例 #20
0
ファイル: URIArg.java プロジェクト: tedvals/fleetmng
 /**
  * ** Decodes the specified hex-encoded argument (not yet fully tested) ** @param sb The
  * StringBuffer where the decoded String argument will be placed ** @param s The String to decode
  * ** @return The StringBuffer where the decoded String will be placed
  */
 public static StringBuffer decodeArg(StringBuffer sb, String s) {
   if (sb == null) {
     sb = new StringBuffer();
   }
   if (s != null) {
     char ch[] = new char[s.length()];
     s.getChars(0, s.length(), ch, 0);
     for (int i = 0; i < ch.length; i++) {
       if (ch[i] == '%') {
         if ((i + 2) < ch.length) {
           int ch1 = StringTools.hexIndex(ch[i + 1]);
           int ch2 = StringTools.hexIndex(ch[i + 2]);
           sb.append((char) (((ch1 << 4) | ch2) & 0xFF));
           i += 2;
         } else {
           i = ch.length - 1;
         }
       } else {
         sb.append(ch[i]);
       }
     }
   }
   return sb;
 }
コード例 #21
0
ファイル: SqlBuilderC.java プロジェクト: markfussell/form
  /** Access is incapable of executing the following correctly with DISTINCTS on count columns */
  public String sqlString() {
    StringBuffer stringB = new StringBuffer();
    if (isCount) {
      stringB.append("SELECT ");
      stringB.append("COUNT(*) ");
    } else {
      if (sqlSelectStringB.length() > 0) {
        stringB.append("SELECT ");
        if (isDistinct) stringB.append("DISTINCT ");
        stringB.append(sqlSelectStringB.toString());
        stringB.append(" ");
      }
      ;
    }

    stringB.append("FROM ");
    stringB.append(sqlExtentStringB.toString());
    if (sqlQueryStringB.length() > 0) {
      stringB.append("WHERE ");
      stringB.append(sqlQueryStringB.toString());
    }
    ;
    return stringB.toString();
  }
コード例 #22
0
ファイル: Main_1.java プロジェクト: Rahul2025/Thesis
 /** @param args the command line arguments */
 public static void main(String[] args) {
   // TODO code application logic here
   try {
     Parserdoubt p = new Parserdoubt(System.in);
     int t = p.nextInt();
     StringBuffer sb = new StringBuffer();
     while (t-- > 0) {
       int a = p.nextInt();
       int b = p.nextInt();
       int c = p.nextInt();
       sb.append(find(a, b, c) + "\n");
     }
     System.out.print(sb.toString());
   } catch (Exception e) {
   }
 }
コード例 #23
0
ファイル: uva619.java プロジェクト: de-yu/uva
 public static void num(String str) {
   BigInteger a = new BigInteger(str);
   StringBuffer sb = new StringBuffer("");
   StringBuffer n = new StringBuffer("");
   while (!(a.divide(div).equals(zero))) {
     sb.insert(0, (char) (a.mod(div).intValue() + 96));
     a = a.divide(div);
   }
   sb.insert(0, (char) (a.intValue() + 96));
   for (int i = 0; i < str.length(); i++) {
     if (i % 3 == 0 && i != 0) n.insert(0, ",");
     n.insert(0, str.charAt(str.length() - i - 1));
   }
   while (sb.length() < 22) sb.append(" ");
   System.out.println(sb + "" + n);
 }
コード例 #24
0
ファイル: Ejer12.java プロジェクト: kalamar23/Ejercicios
  // crear una sucesion de cuadrados
  static void cuadrado() {
    // 1, 4, 9, 16, 25, 36, 49, 64, 81,
    try {
      String s1 =
          JOptionPane.showInputDialog(
              "Ingrese un numero hasta la que desea ver la sucesion de cuadrados :");
      int limite = Integer.parseInt(s1);
      StringBuffer sb = new StringBuffer();
      for (int numero = 1, sqrt = 1; numero < limite; sqrt = ++numero * numero) {
        sb.append(sqrt + " , ");
      }

      int largo = sb.length();
      JOptionPane.showMessageDialog(null, "Sucesion sqrt = " + sb.delete(largo - 2, largo));
    } catch (NumberFormatException e) {
      JOptionPane.showMessageDialog(null, "No ha ingresado un numero !");
    }
  }
コード例 #25
0
ファイル: DTOBDFault.java プロジェクト: tedvals/fleetmng
 public static String GetPropertyString_OBDII(String dtcStr) {
   StringBuffer sb = new StringBuffer();
   sb.append(PROP_TYPE[0]).append("=").append(NAME_OBDII);
   sb.append(" ");
   if (!StringTools.isBlank(dtcStr)) {
     sb.append(PROP_MIL[0]).append("=").append("1");
     sb.append(" ");
     sb.append(PROP_DTC[0]).append("=").append(dtcStr);
   } else {
     sb.append(PROP_MIL[0]).append("=").append("0");
   }
   return sb.toString();
 }
コード例 #26
0
 private InputStream getReport(
     HttpServletRequest request,
     HttpServletResponse response,
     Tab tab,
     TableModel tableModel,
     Integer columnCountLimit)
     throws ServletException, IOException {
   StringBuffer suri = new StringBuffer();
   suri.append("/xava/jasperReport");
   suri.append("?language=");
   suri.append(Locales.getCurrent().getLanguage());
   suri.append("&widths=");
   suri.append(Arrays.toString(getWidths(tableModel)));
   if (columnCountLimit != null) {
     suri.append("&columnCountLimit=");
     suri.append(columnCountLimit);
   }
   response.setCharacterEncoding(XSystem.getEncoding());
   return Servlets.getURIAsStream(request, response, suri.toString());
 }
コード例 #27
0
 /**
  * Gets the instances of <CODE>Template</CODE> that have an ID that is already in the database.
  *
  * @return An <CODE>ArrayList</CODE> containing the instances of <CODE>Template</CODE> already in
  *     the database.
  * @throws java.sql.SQLException Thrown on sql exception.
  */
 public ArrayList findTemplatesInDatabase() throws java.sql.SQLException {
   ArrayList templatesInDatabase = new ArrayList();
   Connection oracleConnection = getDataSource().getConnection();
   try {
     Statement query = oracleConnection.createStatement();
     try {
       StringBuffer sql = new StringBuffer("SELECT TMPL_ID FROM ");
       sql.append(MPSBrowserView.SCHEMA);
       sql.append(".TEMPLATE WHERE TMPL_ID IN (");
       ArrayList templates = getTemplates();
       int templateCount = templates.size();
       for (int i = 0; i < templateCount; i++) {
         if (i > 0) sql.append(", ");
         sql.append("'");
         sql.append(((Template) templates.get(i)).getID());
         sql.append("'");
       }
       sql.append(")");
       ResultSet result = query.executeQuery(sql.toString());
       try {
         while (result.next()) {
           String templateID = result.getString("TMPL_ID");
           for (int i = 0; i < templateCount; i++) {
             Template currentTemplate = (Template) templates.get(i);
             if (templateID.equals(currentTemplate.getID())) {
               templatesInDatabase.add(currentTemplate);
               currentTemplate.setInDatabase(true);
             }
           }
         }
       } finally {
         result.close();
       }
     } finally {
       query.close();
     }
   } finally {
     oracleConnection.close();
   }
   return templatesInDatabase;
 }
コード例 #28
0
ファイル: DTOBDFault.java プロジェクト: tedvals/fleetmng
 public static String GetFaultDescription(long fault, Locale locale) {
   if (fault != 0L) {
     String fmt = "000";
     StringBuffer sb = new StringBuffer();
     if ((fault & TYPE_MASK) == TYPE_J1708) {
       int mid = DTOBDFault.DecodeSystem(fault); // MID
       boolean isSid = DTOBDFault.IsJ1708_SID(fault);
       int pidSid = DTOBDFault.DecodePidSid(fault); // PID|SID "128/[s]123/1"
       int fmi = DTOBDFault.DecodeFMI(fault); // FMI
       Properties p =
           (j1587DescProvider != null)
               ? j1587DescProvider.getJ1587Descriptions(fault)
               : new Properties();
       // MID
       sb.append(
           NAME_MID
               + "("
               + StringTools.format(mid, fmt)
               + ") "
               + p.getProperty(NAME_MID_DESC, "")
               + "\n");
       // PID/SID
       if (isSid) {
         sb.append(
             NAME_SID
                 + "("
                 + StringTools.format(pidSid, fmt)
                 + ") "
                 + p.getProperty(NAME_SID_DESC, "")
                 + "\n");
       } else {
         sb.append(
             NAME_PID
                 + "("
                 + StringTools.format(pidSid, fmt)
                 + ") "
                 + p.getProperty(NAME_PID_DESC, "")
                 + "\n");
       }
       // FMI
       sb.append(
           NAME_FMI
               + "("
               + StringTools.format(fmi, fmt)
               + ") "
               + p.getProperty(NAME_FMI_DESC, ""));
       return sb.toString();
     } else if ((fault & TYPE_MASK) == TYPE_J1939) {
       int spn = DTOBDFault.DecodeSystem(fault); // SPN
       int fmi = DTOBDFault.DecodeFMI(fault); // FMI
       Properties p = new Properties();
       // SPN
       sb.append(
           NAME_SPN
               + "("
               + StringTools.format(spn, fmt)
               + ") "
               + p.getProperty(NAME_SPN, "")
               + "\n");
       // FMI
       sb.append(
           NAME_FMI + "(" + StringTools.format(fmi, fmt) + ") " + p.getProperty(NAME_FMI, ""));
       return sb.toString();
     } else if ((fault & TYPE_MASK) == TYPE_OBDII) {
       String dtc = DTOBDFault.GetFaultString(fault); // DTC
       Properties p = new Properties();
       // DTC
       sb.append(NAME_DTC + "(" + dtc + ") " + p.getProperty(NAME_DTC, ""));
       return sb.toString();
     }
   }
   return "";
 }
コード例 #29
0
ファイル: CityDaoExample.java プロジェクト: rmage/gnvc-ims
 /**
  * Method 'display'
  *
  * @param dto
  */
 public static void display(City dto) {
   StringBuffer buf = new StringBuffer();
   buf.append(dto.getCityCode());
   buf.append(", ");
   buf.append(dto.getName());
   buf.append(", ");
   buf.append(dto.getCreatedBy());
   buf.append(", ");
   buf.append(dto.getCreatedDate());
   buf.append(", ");
   buf.append(dto.getUpdatedBy());
   buf.append(", ");
   buf.append(dto.getUpdatedDate());
   System.out.println(buf.toString());
 }
コード例 #30
0
ファイル: TreeLeafDO.java プロジェクト: mlocher-sf/jobmatch
  /**
   * Modifies the DO within its table. Performs recursive commit/delete on referenced DOs; all
   * operations occur within a single transaction to allow rollback in the event of error. Only the
   * creator of the transaction releases it.
   *
   * @param dbt The transaction object to use for this operation.
   * @param delete True if doing a delete, otherwise doing insert/update.
   * @exception com.lutris.appserver.server.sql.DatabaseManagerException if a Transaction can not be
   *     created.
   * @exception com.lutris.appserver.server.sql.DBRowUpdateException if a version error occurs.
   * @exception RefAssertionException thrown by okTo method.
   * @exception java.sql.SQLException if any SQL errors occur.
   */
  protected void modifyDO(DBTransaction dbt, boolean delete)
      throws SQLException, DatabaseManagerException, DataObjectException, RefAssertionException,
          DBRowUpdateException, QueryException {
    if (delete) okToDelete();
    else okToCommit();
    boolean ownTransaction = false;
    try {
      if (null == dbt) {
        DatabaseManager dbm = Enhydra.getDatabaseManager();
        dbt = dbm.createTransaction(); // create a transaction
        ownTransaction = true;
      }
      if (null == dbt)
        throw new DatabaseManagerException("DatabaseManager.createTransaction returned null.");
      if (delete) {
        // Code to perform cascading deletes is generated here
        // if cascading deletes are not supported by the database.

        // The following line keeps the compiler happy
        // when the CASCADING_DELETES tag is empty.
        if (false) throw new QueryException("XXX");
      } else {
        // commit referenced DOs.
        jobmatch.data.ProfileDO Profile_DO = getProfile();
        if (null != Profile_DO) {
          if (Profile_DO.isLoaded()) {
            okToCommitProfile(Profile_DO);
            Profile_DO.commit(dbt);
          } else {
            // since the referenced DO is not loaded,
            // it cannot be dirty, so there is no need to commit it.
          }
        } else {
          if (!false)
            throw new RefAssertionException(
                "Cannot commit TreeLeafDO ( "
                    + toString()
                    + " ) because Profile is not allowed to be null.");
        }
      }
      if (false) {
        // This throw is here to keep the compiler happy
        // in the case of a DO that does not refer to other DOs.
        // In that case, the above delete/commit code blocks will be empty
        // and throw nothing.
        throw new DataObjectException("foo");
      }
      if (delete) {
        dbt.delete(this);
      } else {
        if (isLoaded()) dbt.insert(this); // dbt.insert() handles insertions and updates
      }
      if (ownTransaction) {
        dbt.commit(); // commit the transaction
      }
    } catch (SQLException sqle) {
      StringBuffer message = new StringBuffer("Failed to insert/update DO: ");
      message.append(sqle.getMessage());

      // rollback, if necessary
      if (ownTransaction) {
        try {
          dbt.rollback();
        } catch (SQLException sqle2) {
          message.insert(0, "\n");
          message.insert(0, sqle2.getMessage());
          message.insert(0, "Rollback failed: ");
        }
      }
      throw new SQLException(message.toString());
    } finally {
      // release the transaction, if any
      if (ownTransaction) {
        dbt.release();
      }
    }
  }