/**
   * Maps attributes of an SQL structured type that are not serialized to a serialized form, using
   * the given type map for custom mapping when appropriate. The following types in the Java
   * programming language are mapped to their serialized forms: <code>Struct</code>, <code>SQLData
   * </code>, <code>Ref</code>, <code>Blob</code>, <code>Clob</code>, and <code>Array</code>.
   *
   * <p>This method is called internally and is not used by an application programmer.
   *
   * @param map a <code>java.util.Map</code> object in which each entry consists of 1) a <code>
   *     String</code> object giving the fully qualified name of a UDT and 2) the <code>Class</code>
   *     object for the <code>SQLData</code> implementation that defines how the UDT is to be mapped
   * @throws SerialException if an error occurs
   */
  private void mapToSerial(Map map) throws SerialException {

    try {

      for (int i = 0; i < attribs.length; i++) {
        if (attribs[i] instanceof Struct) {
          attribs[i] = new SerialStruct((Struct) attribs[i], map);
        } else if (attribs[i] instanceof SQLData) {
          attribs[i] = new SerialStruct((SQLData) attribs[i], map);
        } else if (attribs[i] instanceof Blob) {
          attribs[i] = new SerialBlob((Blob) attribs[i]);
        } else if (attribs[i] instanceof Clob) {
          attribs[i] = new SerialClob((Clob) attribs[i]);
        } else if (attribs[i] instanceof Ref) {
          attribs[i] = new SerialRef((Ref) attribs[i]);
        } else if (attribs[i] instanceof java.sql.Array) {
          attribs[i] = new SerialArray((java.sql.Array) attribs[i], map);
        }
      }

    } catch (SQLException e) {
      throw new SerialException(e.getMessage());
    }
    return;
  }
 public CFSecuritySecDeviceBuff[] readBuffByUserIdx(
     CFSecurityAuthorization Authorization, UUID SecUserId) {
   final String S_ProcName = "readBuffByUserIdx";
   ResultSet resultSet = null;
   try {
     Connection cnx = schema.getCnx();
     String sql =
         "call "
             + schema.getLowerDbSchemaName()
             + ".sp_read_secdev_by_useridx( ?, ?, ?, ?, ?"
             + ", "
             + "?"
             + " )";
     if (stmtReadBuffByUserIdx == null) {
       stmtReadBuffByUserIdx = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtReadBuffByUserIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadBuffByUserIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtReadBuffByUserIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtReadBuffByUserIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadBuffByUserIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtReadBuffByUserIdx.setString(argIdx++, SecUserId.toString());
     try {
       resultSet = stmtReadBuffByUserIdx.executeQuery();
     } catch (SQLException e) {
       if (e.getErrorCode() != 1329) {
         throw e;
       }
       resultSet = null;
     }
     List<CFSecuritySecDeviceBuff> buffList = new LinkedList<CFSecuritySecDeviceBuff>();
     while ((resultSet != null) && resultSet.next()) {
       CFSecuritySecDeviceBuff buff = unpackSecDeviceResultSetToBuff(resultSet);
       buffList.add(buff);
     }
     int idx = 0;
     CFSecuritySecDeviceBuff[] retBuff = new CFSecuritySecDeviceBuff[buffList.size()];
     Iterator<CFSecuritySecDeviceBuff> iter = buffList.iterator();
     while (iter.hasNext()) {
       retBuff[idx++] = iter.next();
     }
     return (retBuff);
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
 public CFSecurityISOCountryLanguageBuff[] readAllBuff(CFSecurityAuthorization Authorization) {
   final String S_ProcName = "readAllBuff";
   if (!schema.isTransactionOpen()) {
     throw CFLib.getDefaultExceptionFactory()
         .newUsageException(getClass(), S_ProcName, "Transaction not open");
   }
   ResultSet resultSet = null;
   try {
     Connection cnx = schema.getCnx();
     String sql =
         "call " + schema.getLowerDbSchemaName() + ".sp_read_iso_cntrylng_all( ?, ?, ?, ?, ? )";
     if (stmtReadAllBuff == null) {
       stmtReadAllBuff = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtReadAllBuff.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadAllBuff.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtReadAllBuff.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtReadAllBuff.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadAllBuff.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     try {
       resultSet = stmtReadAllBuff.executeQuery();
     } catch (SQLException e) {
       if (e.getErrorCode() != 1329) {
         throw e;
       }
       resultSet = null;
     }
     List<CFSecurityISOCountryLanguageBuff> buffList =
         new LinkedList<CFSecurityISOCountryLanguageBuff>();
     while ((resultSet != null) && resultSet.next()) {
       CFSecurityISOCountryLanguageBuff buff = unpackISOCountryLanguageResultSetToBuff(resultSet);
       buffList.add(buff);
     }
     int idx = 0;
     CFSecurityISOCountryLanguageBuff[] retBuff =
         new CFSecurityISOCountryLanguageBuff[buffList.size()];
     Iterator<CFSecurityISOCountryLanguageBuff> iter = buffList.iterator();
     while (iter.hasNext()) {
       retBuff[idx++] = iter.next();
     }
     return (retBuff);
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
  /**
   * Constructs a <code>SerialStruct</code> object from the given <code>SQLData</code> object, using
   * the given type map to custom map it to a class in the Java programming language. The type map
   * gives the SQL type and the class to which it is mapped. The <code>SQLData</code> object defines
   * the class to which the SQL type will be mapped.
   *
   * @param in an instance of the <code>SQLData</code> class that defines the mapping of the SQL
   *     structured type to one or more objects in the Java programming language
   * @param map a <code>java.util.Map</code> object in which each entry consists of 1) a <code>
   *     String</code> object giving the fully qualified name of a UDT and 2) the <code>Class</code>
   *     object for the <code>SQLData</code> implementation that defines how the UDT is to be mapped
   * @throws SerialException if an error occurs
   */
  public SerialStruct(SQLData in, Map<String, Class<?>> map) throws SerialException {

    try {

      // set the type name
      SQLTypeName = new String(in.getSQLTypeName());

      Vector tmp = new Vector();
      in.writeSQL(new SQLOutputImpl(tmp, map));
      attribs = tmp.toArray();

    } catch (SQLException e) {
      throw new SerialException(e.getMessage());
    }
  }
  /**
   * Constructs a <code>SerialStruct</code> object from the given <code>Struct</code> object, using
   * the given <code>java.util.Map</code> object for custom mapping the SQL structured type or any
   * of its attributes that are SQL structured types.
   *
   * @param map a <code>java.util.Map</code> object in which each entry consists of 1) a <code>
   *     String</code> object giving the fully qualified name of a UDT and 2) the <code>Class</code>
   *     object for the <code>SQLData</code> implementation that defines how the UDT is to be mapped
   * @throws SerialException if an error occurs
   * @see java.sql.Struct
   */
  public SerialStruct(Struct in, Map<String, Class<?>> map) throws SerialException {

    try {

      // get the type name
      SQLTypeName = new String(in.getSQLTypeName());
      System.out.println("SQLTypeName: " + SQLTypeName);

      // get the attributes of the struct
      attribs = in.getAttributes(map);

      /*
       * the array may contain further Structs
       * and/or classes that have been mapped,
       * other types that we have to serialize
       */
      mapToSerial(map);

    } catch (SQLException e) {
      throw new SerialException(e.getMessage());
    }
  }
Exemple #6
0
  /**
   * 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();
      }
    }
  }
 public void updateISOLanguage(
     CFSecurityAuthorization Authorization, CFSecurityISOLanguageBuff Buff) {
   final String S_ProcName = "updateISOLanguage";
   ResultSet resultSet = null;
   try {
     short ISOLanguageId = Buff.getRequiredISOLanguageId();
     String ISO6392Code = Buff.getRequiredISO6392Code();
     String ISO6391Code = Buff.getOptionalISO6391Code();
     String EnglishName = Buff.getRequiredEnglishName();
     int Revision = Buff.getRequiredRevision();
     Connection cnx = schema.getCnx();
     String sql =
         "call "
             + schema.getLowerDbSchemaName()
             + ".sp_update_iso_lang( ?, ?, ?, ?, ?, ?"
             + ", "
             + "?"
             + ", "
             + "?"
             + ", "
             + "?"
             + ", "
             + "?"
             + ", "
             + "?"
             + " )";
     if (stmtUpdateByPKey == null) {
       stmtUpdateByPKey = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtUpdateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtUpdateByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtUpdateByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtUpdateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtUpdateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtUpdateByPKey.setString(argIdx++, "ISLN");
     stmtUpdateByPKey.setShort(argIdx++, ISOLanguageId);
     stmtUpdateByPKey.setString(argIdx++, ISO6392Code);
     if (ISO6391Code != null) {
       stmtUpdateByPKey.setString(argIdx++, ISO6391Code);
     } else {
       stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
     }
     stmtUpdateByPKey.setString(argIdx++, EnglishName);
     stmtUpdateByPKey.setInt(argIdx++, Revision);
     try {
       resultSet = stmtUpdateByPKey.executeQuery();
     } catch (SQLException e) {
       if (e.getErrorCode() != 1329) {
         throw e;
       }
       resultSet = null;
     }
     if ((resultSet != null) && resultSet.next()) {
       CFSecurityISOLanguageBuff updatedBuff = unpackISOLanguageResultSetToBuff(resultSet);
       if ((resultSet != null) && resultSet.next()) {
         resultSet.last();
         throw CFLib.getDefaultExceptionFactory()
             .newRuntimeException(
                 getClass(),
                 S_ProcName,
                 "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
       }
       Buff.setRequiredISO6392Code(updatedBuff.getRequiredISO6392Code());
       Buff.setOptionalISO6391Code(updatedBuff.getOptionalISO6391Code());
       Buff.setRequiredEnglishName(updatedBuff.getRequiredEnglishName());
       Buff.setRequiredRevision(updatedBuff.getRequiredRevision());
     } else {
       throw CFLib.getDefaultExceptionFactory()
           .newRuntimeException(
               getClass(),
               S_ProcName,
               "Expected a single-record response, " + resultSet.getRow() + " rows selected");
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
 public CFSecurityISOLanguageBuff readBuffByCode3Idx(
     CFSecurityAuthorization Authorization, String ISO6392Code) {
   final String S_ProcName = "readBuffByCode3Idx";
   ResultSet resultSet = null;
   try {
     Connection cnx = schema.getCnx();
     String sql =
         "call "
             + schema.getLowerDbSchemaName()
             + ".sp_read_iso_lang_by_code3idx( ?, ?, ?, ?, ?"
             + ", "
             + "?"
             + " )";
     if (stmtReadBuffByCode3Idx == null) {
       stmtReadBuffByCode3Idx = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtReadBuffByCode3Idx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadBuffByCode3Idx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtReadBuffByCode3Idx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtReadBuffByCode3Idx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadBuffByCode3Idx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtReadBuffByCode3Idx.setString(argIdx++, ISO6392Code);
     try {
       resultSet = stmtReadBuffByCode3Idx.executeQuery();
     } catch (SQLException e) {
       if (e.getErrorCode() != 1329) {
         throw e;
       }
       resultSet = null;
     }
     if ((resultSet != null) && resultSet.next()) {
       CFSecurityISOLanguageBuff buff = unpackISOLanguageResultSetToBuff(resultSet);
       if ((resultSet != null) && resultSet.next()) {
         resultSet.last();
         throw CFLib.getDefaultExceptionFactory()
             .newRuntimeException(
                 getClass(),
                 S_ProcName,
                 "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
       }
       return (buff);
     } else {
       return (null);
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
 public CFSecurityISOLanguageBuff lockBuff(
     CFSecurityAuthorization Authorization, CFSecurityISOLanguagePKey PKey) {
   final String S_ProcName = "lockBuff";
   if (!schema.isTransactionOpen()) {
     throw CFLib.getDefaultExceptionFactory()
         .newUsageException(getClass(), S_ProcName, "Transaction not open");
   }
   ResultSet resultSet = null;
   try {
     Connection cnx = schema.getCnx();
     short ISOLanguageId = PKey.getRequiredISOLanguageId();
     String sql =
         "call "
             + schema.getLowerDbSchemaName()
             + ".sp_lock_iso_lang( ?, ?, ?, ?, ?"
             + ", "
             + "?"
             + " )";
     if (stmtLockBuffByPKey == null) {
       stmtLockBuffByPKey = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtLockBuffByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtLockBuffByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtLockBuffByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtLockBuffByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtLockBuffByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtLockBuffByPKey.setShort(argIdx++, ISOLanguageId);
     try {
       resultSet = stmtLockBuffByPKey.executeQuery();
     } catch (SQLException e) {
       if (e.getErrorCode() != 1329) {
         throw e;
       }
       resultSet = null;
     }
     if ((resultSet != null) && resultSet.next()) {
       CFSecurityISOLanguageBuff buff = unpackISOLanguageResultSetToBuff(resultSet);
       if ((resultSet != null) && resultSet.next()) {
         resultSet.last();
         throw CFLib.getDefaultExceptionFactory()
             .newRuntimeException(
                 getClass(),
                 S_ProcName,
                 "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
       }
       return (buff);
     } else {
       return (null);
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
 public void createSecDevice(CFSecurityAuthorization Authorization, CFSecuritySecDeviceBuff Buff) {
   final String S_ProcName = "createSecDevice";
   if (!schema.isTransactionOpen()) {
     throw CFLib.getDefaultExceptionFactory()
         .newUsageException(getClass(), S_ProcName, "Transaction not open");
   }
   ResultSet resultSet = null;
   try {
     UUID SecUserId = Buff.getRequiredSecUserId();
     String DevName = Buff.getRequiredDevName();
     String PubKey = Buff.getOptionalPubKey();
     Connection cnx = schema.getCnx();
     String sql =
         "call "
             + schema.getLowerDbSchemaName()
             + ".sp_create_secdev( ?, ?, ?, ?, ?, ?"
             + ", "
             + "?"
             + ", "
             + "?"
             + ", "
             + "?"
             + " )";
     if (stmtCreateByPKey == null) {
       stmtCreateByPKey = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtCreateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtCreateByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtCreateByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtCreateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtCreateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtCreateByPKey.setString(argIdx++, "SDEV");
     stmtCreateByPKey.setString(argIdx++, SecUserId.toString());
     stmtCreateByPKey.setString(argIdx++, DevName);
     if (PubKey != null) {
       stmtCreateByPKey.setString(argIdx++, PubKey);
     } else {
       stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
     }
     try {
       resultSet = stmtCreateByPKey.executeQuery();
     } catch (SQLException e) {
       if (e.getErrorCode() != 1329) {
         throw e;
       }
       resultSet = null;
     }
     if ((resultSet != null) && resultSet.next()) {
       CFSecuritySecDeviceBuff createdBuff = unpackSecDeviceResultSetToBuff(resultSet);
       if ((resultSet != null) && resultSet.next()) {
         resultSet.last();
         throw CFLib.getDefaultExceptionFactory()
             .newRuntimeException(
                 getClass(),
                 S_ProcName,
                 "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
       }
       Buff.setRequiredSecUserId(createdBuff.getRequiredSecUserId());
       Buff.setRequiredDevName(createdBuff.getRequiredDevName());
       Buff.setOptionalPubKey(createdBuff.getOptionalPubKey());
       Buff.setRequiredRevision(createdBuff.getRequiredRevision());
       Buff.setCreatedByUserId(createdBuff.getCreatedByUserId());
       Buff.setCreatedAt(createdBuff.getCreatedAt());
       Buff.setUpdatedByUserId(createdBuff.getUpdatedByUserId());
       Buff.setUpdatedAt(createdBuff.getUpdatedAt());
     } else {
       throw CFLib.getDefaultExceptionFactory()
           .newRuntimeException(
               getClass(),
               S_ProcName,
               "Expected a single-record response, " + resultSet.getRow() + " rows selected");
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
 public void updateTSecGroup(CFSecurityAuthorization Authorization, CFSecurityTSecGroupBuff Buff) {
   final String S_ProcName = "updateTSecGroup";
   ResultSet resultSet = null;
   try {
     long TenantId = Buff.getRequiredTenantId();
     int TSecGroupId = Buff.getRequiredTSecGroupId();
     String Name = Buff.getRequiredName();
     int Revision = Buff.getRequiredRevision();
     Connection cnx = schema.getCnx();
     String sql =
         "call "
             + schema.getLowerDbSchemaName()
             + ".sp_update_tsecgrp( ?, ?, ?, ?, ?, ?"
             + ", "
             + "?"
             + ", "
             + "?"
             + ", "
             + "?"
             + ", "
             + "?"
             + " )";
     if (stmtUpdateByPKey == null) {
       stmtUpdateByPKey = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtUpdateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtUpdateByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtUpdateByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtUpdateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtUpdateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtUpdateByPKey.setString(argIdx++, "TGRP");
     stmtUpdateByPKey.setLong(argIdx++, TenantId);
     stmtUpdateByPKey.setInt(argIdx++, TSecGroupId);
     stmtUpdateByPKey.setString(argIdx++, Name);
     stmtUpdateByPKey.setInt(argIdx++, Revision);
     try {
       resultSet = stmtUpdateByPKey.executeQuery();
     } catch (SQLException e) {
       if (e.getErrorCode() != 1329) {
         throw e;
       }
       resultSet = null;
     }
     if ((resultSet != null) && resultSet.next()) {
       CFSecurityTSecGroupBuff updatedBuff = unpackTSecGroupResultSetToBuff(resultSet);
       if ((resultSet != null) && resultSet.next()) {
         resultSet.last();
         throw CFLib.getDefaultExceptionFactory()
             .newRuntimeException(
                 getClass(),
                 S_ProcName,
                 "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
       }
       Buff.setRequiredName(updatedBuff.getRequiredName());
       Buff.setRequiredRevision(updatedBuff.getRequiredRevision());
     } else {
       throw CFLib.getDefaultExceptionFactory()
           .newRuntimeException(
               getClass(),
               S_ProcName,
               "Expected a single-record response, " + resultSet.getRow() + " rows selected");
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }