Beispiel #1
1
  /**
   * Determine the type of attachment, based on file extension, and add it to the elog entry with
   * the entry_id.
   *
   * @param fname input filename, either an image or a text file
   * @param fileType "I" for image file, "A" for text file
   * @param entry_id ID of entry to which to add this file
   * @param caption Caption or 'title' for the attachment
   * @throws Exception
   */
  private void addFileToElog(
      final String fname, String fileType, final int entry_id, final String caption)
      throws Exception {
    // Get the file extension
    final int ndx = fname.lastIndexOf(".");
    final String extension = fname.substring(ndx + 1);
    long fileTypeID = getFileTypeId(fileType, extension);

    // If the image type cannot be found in the RDB, change its file type to
    // an attachment and look for the
    // extension as an attachment
    if (fileTypeID == -1 && fileType.equals("I")) {
      fileType = "A";
      fileTypeID = getFileTypeId(fileType, extension);
    }

    // Initiate the sql to add attachments to the elog
    final String mysql = "call logbook.logbook_pkg.add_entry_attachment" + "(?, ?, ?, ?, ?)";
    final Connection connection = rdb.getConnection();
    final CallableStatement statement = connection.prepareCall(mysql);
    try {
      statement.setInt(1, entry_id);
      statement.setString(2, fileType);
      statement.setString(3, caption);
      statement.setLong(4, fileTypeID);
      final File inputFile = new File(fname);

      // Send the image to the sql.
      if (fileType.equals("I")) {
        try {
          final int file_size = (int) inputFile.length();
          final FileInputStream input_stream = new FileInputStream(inputFile);
          statement.setBinaryStream(5, input_stream, file_size);
          input_stream.close();
        } catch (FileNotFoundException e1) {
          System.out.println("Could not find " + fname);
          return;
        }
      }
      // Send the text attachment to the sql
      else {
        // Create a Blob to store the attachment in.
        final BLOB blob = BLOB.createTemporary(connection, true, BLOB.DURATION_SESSION);
        blob.setBytes(1L, getBytesFromFile(inputFile));
        statement.setBlob(5, blob);
      }
      statement.executeQuery();
    } finally {
      statement.close();
    }
  }
  public static Couple<String, String> gift(
      int giftGameID, long matchID, long uid, String uids, int number)
      throws SQLException, SimpleException {
    String query = "{call MakeGiftGame(?,?,?,?,?)}";
    int res = 0;
    try (Connection conn = DBPoolConnection.getConnection()) {
      CallableStatement cs = conn.prepareCall(query);
      cs.clearParameters();
      cs.setLong(1, uid);
      cs.setLong(2, matchID);
      cs.setInt(3, number);
      cs.setString(4, uids);
      cs.setInt(5, giftGameID);

      ResultSet rs = cs.executeQuery();
      if (rs != null && rs.next()) {
        res = rs.getInt("result");
      }
    }
    if (res == 1) {
      return giftGameChat(giftGameID);
    } else {
      throw new SimpleException("Không tặng được");
    }
  }
 public Tour insertTour(Tour rec) {
   Tour flag = null;
   try {
     DBCON ob = new DBCON();
     Connection con = null;
     CallableStatement cs = null;
     con = ob.createConnection();
     cs = con.prepareCall("{call trs_srilanka.insertTour(?,?,?,?,?,?,?)}");
     cs.setLong(1, rec.getTRID());
     cs.setString(2, rec.getTitle());
     cs.setString(3, rec.getItinary());
     cs.setString(4, rec.getNoOfDays());
     cs.setString(5, rec.getAccomadationType());
     cs.setString(6, rec.getBasis());
     cs.setLong(7, rec.getGEOID());
     int res = cs.executeUpdate();
     if (res > 0) {
       flag = rec;
     } else {
       flag = null;
     }
   } catch (Exception ex) {
     ex.printStackTrace();
   }
   return flag;
 }
Beispiel #4
0
  public void callProcAggiornaAbilitazione(
      Long idVersioneInterventoTu, Long idAzioneFas, Long idProgrammaPoc, Long idObiettivoSpecifico)
      throws ApplicationException {

    getLogger().debug("callProcAggiornaAbilitazioni  inizio");
    Session session = super.getSession();
    CallableStatement cs;
    try {
      cs = super.getConnection(session).prepareCall("{ call  DBP_AGGIORNA_ABILITAZIONI(?,?,?,?) }");
      cs.setLong(1, idVersioneInterventoTu.longValue());

      if (idAzioneFas != null) cs.setLong(2, idAzioneFas.longValue());
      else cs.setObject(2, null);

      if (idProgrammaPoc != null) cs.setLong(3, idProgrammaPoc.longValue());
      else cs.setObject(3, null);

      if (idObiettivoSpecifico != null) cs.setLong(4, idObiettivoSpecifico.longValue());
      else cs.setObject(4, null);

      cs.execute();
      getLogger().debug("DBP_AGGIORNA_ABILITAZIONI eseguita.");
    } catch (Exception e) {
      e.printStackTrace();
      getLogger().debug("----------------------errore plsql callProcAggiornaAbilitazioni");
      throw new ApplicationException("errore plsql callProcAggiornaAbilitazioni");
    } finally {
      session.close();
    }
  }
Beispiel #5
0
  public void save(Connection conn, AccountingArMgr accMgr, int rowIndex) throws SQLException {

    CallableStatement cstmt = null;
    String verbEntryMode = accMgr.getEntryMode().split("-")[0];

    try {
      this.mCode = 0;
      String sql =
          "begin FM_AR_PAYMENT_TERM_DETAIL_PKG.SAVE(:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11); end;";
      cstmt = conn.prepareCall(sql);
      DeBug.print(sql);

      cstmt.setLong(1, Long.parseLong(accMgr.getCurrentMiscellaneousInvoice().getInvoiceId()));
      cstmt.setLong(2, Long.parseLong(this.getPaymentTerm().getAttributeCode()));
      cstmt.setDouble(3, Double.parseDouble(this.getPercentage()));
      cstmt.setString(
          4, Decoder.convertSetString(accMgr.getCurrentMiscellaneousInvoice().getStartDate()));
      cstmt.setNull(5, Types.VARCHAR);
      cstmt.setNull(6, Types.VARCHAR);
      cstmt.setString(
          7, Decoder.convertSetString(accMgr.getCurrentMiscellaneousInvoice().getSourceType()));
      cstmt.setString(8, Decoder.convertSetString(verbEntryMode));
      cstmt.setLong(9, rowIndex);

      cstmt.registerOutParameter(10, Types.INTEGER);
      cstmt.registerOutParameter(11, Types.VARCHAR);
      cstmt.execute();

      int returnCode = cstmt.getInt(10);
      String returnMessage = cstmt.getString(11);

      if (returnCode == -2) {
        // Violate unique constraint in database
        this.mCode = UNIQUE_VIOLATION;
        throw new SQLException(returnMessage);
      } else if (returnCode != 0) {
        // Non-manageable error.
        this.mCode = SAVE_ERROR;
        throw new SQLException(returnMessage);
      }
    } catch (Exception e) {
      this.mCode = SAVE_ERROR;
      e.printStackTrace();
      throw new SQLException(e.getMessage());
    } finally {
      if (cstmt != null) {
        cstmt.close();
      }
      cstmt = null;
    }
  }
 public void ThisSet(long ServiceId, PersistentService ThisVal) throws PersistenceException {
   try {
     CallableStatement callable;
     callable =
         this.con.prepareCall("Begin " + this.schemaName + ".SrvcFacade.ThisSet(?, ?, ?); end;");
     callable.setLong(1, ServiceId);
     callable.setLong(2, ThisVal.getId());
     callable.setLong(3, ThisVal.getClassId());
     callable.execute();
     callable.close();
   } catch (SQLException se) {
     throw new PersistenceException(se.getMessage(), se.getErrorCode());
   }
 }
  @Override
  public void procesar(MotEmpConductor dto) throws MotEmpConductorDaoException {

    Connection conn = null;
    CallableStatement stmt = null;
    ResultSet rs = null;

    try {
      conn = ResourceManager.getConnection();
      stmt =
          conn.prepareCall(
              "{call SP_MOT_INS_PERSONA_CONDUCTOR;1(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}");
      stmt.registerOutParameter(1, Types.DECIMAL);
      stmt.setLong(1, dto.getConductor().getConcodigoD());
      stmt.setLong(2, dto.getConductor().getPersona().getPercodigoD());
      stmt.setString(3, dto.getConductor().getPersona().getPerdniV());
      stmt.setString(4, dto.getConductor().getPersona().getPernombresV());
      stmt.setString(5, dto.getConductor().getPersona().getPerpaternoV());
      stmt.setString(6, dto.getConductor().getPersona().getPermaternoV());
      stmt.setString(7, dto.getConductor().getPersona().getPernacimientoF());
      stmt.setString(8, dto.getConductor().getPersona().getPerestadocivilC());
      stmt.setString(9, dto.getConductor().getPersona().getPermovilclaV());
      stmt.setString(10, dto.getConductor().getPersona().getPermovilmovV());
      stmt.setString(11, dto.getConductor().getPersona().getPermovilnexV());
      stmt.setString(12, dto.getConductor().getPersona().getPerteleffijoV());
      stmt.setString(13, dto.getConductor().getPersona().getPeremailV());
      stmt.setString(14, dto.getConductor().getPersona().getPerdomicilioV());
      stmt.setString(15, dto.getConductor().getPersona().getPerubidistV());
      stmt.setString(16, dto.getConductor().getPersona().getPerubdptoV());
      stmt.setString(17, dto.getConductor().getPersona().getPerubprovV());
      stmt.setString(18, dto.getConductor().getPersona().getPersexoC());
      stmt.setLong(19, dto.getEmpresa().getEmpcodigoD());
      stmt.setString(20, dto.getEcofechainicioF());
      stmt.execute();

      Long codigo = stmt.getLong(1);
      if (codigo != null) {
        dto.getConductor().setConcodigoD(codigo);
      }

    } catch (Exception ex) {
      logger.error("Exception: " + ex.getMessage(), ex);
      throw new MotEmpConductorDaoException("Exception: " + ex.getMessage(), ex);
    } finally {
      ResourceManager.close(rs);
      ResourceManager.close(stmt);
      ResourceManager.close(conn);
    }
  }
 @Override
 public List<MotInteInventario> findByInternamiento(Long codigo)
     throws MotInteInventarioDaoException {
   Connection conn = null;
   CallableStatement stmt = null;
   ResultSet rs = null;
   List<MotInteInventario> list = null;
   try {
     conn = ResourceManager.getConnection();
     stmt = conn.prepareCall("{call SP_MOT_GET_INTEINVENTARIOBYINTERNAMIENTO;1(?)}");
     stmt.setLong(1, codigo);
     boolean results = stmt.execute();
     if (results) {
       list = new ArrayList<MotInteInventario>();
       rs = stmt.getResultSet();
       MotInteInventario inventario = null;
       while (rs.next()) {
         inventario = new MotInteInventario();
         inventario.getInternamiento().setIntcodigoD(rs.getLong("INTCODIGO"));
         inventario.getInventarioTipo().setBitcodigoI(rs.getInt("BITCODIGO"));
         inventario.setBivcantidadI(rs.getInt("CANTIDAD"));
         inventario.setBivestadoC(rs.getString("ESTADO"));
         list.add(inventario);
       }
     }
   } catch (SQLException e) {
     throw new MotInteInventarioDaoException(e.getMessage(), e);
   } finally {
     ResourceManager.close(rs);
     ResourceManager.close(stmt);
     ResourceManager.close(conn);
   }
   return list;
 }
  public long nextTSecGroupMemberIdGen(
      CFSecurityAuthorization Authorization, CFSecurityTenantPKey PKey) {
    final String S_ProcName = "nextTSecGroupMemberIdGen";
    if (!schema.isTransactionOpen()) {
      throw CFLib.getDefaultExceptionFactory()
          .newUsageException(getClass(), S_ProcName, "Not in a transaction");
    }
    Connection cnx = schema.getCnx();
    long Id = PKey.getRequiredId();

    CallableStatement stmtSelectNextTSecGroupMemberIdGen = null;
    try {
      String sql = "{ call sp_next_tsecgroupmemberidgen( ?" + ", " + "?" + " ) }";
      stmtSelectNextTSecGroupMemberIdGen = cnx.prepareCall(sql);
      int argIdx = 1;
      stmtSelectNextTSecGroupMemberIdGen.registerOutParameter(argIdx++, java.sql.Types.BIGINT);
      stmtSelectNextTSecGroupMemberIdGen.setLong(argIdx++, Id);
      stmtSelectNextTSecGroupMemberIdGen.execute();
      long nextId = stmtSelectNextTSecGroupMemberIdGen.getLong(1);
      return (nextId);
    } catch (SQLException e) {
      throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
      if (stmtSelectNextTSecGroupMemberIdGen != null) {
        try {
          stmtSelectNextTSecGroupMemberIdGen.close();
        } catch (SQLException e) {
        }
        stmtSelectNextTSecGroupMemberIdGen = null;
      }
    }
  }
Beispiel #10
0
 public User insertUser(User rec) {
   User flag = null;
   try {
     DBCON ob = new DBCON();
     Connection con = null;
     CallableStatement cs = null;
     con = ob.createConnection();
     cs = con.prepareCall("{call trs_srilanka.insertUser(?,?,?,?,?,?,?,?,?,?)}");
     cs.setLong(1, rec.getUSID());
     cs.setString(2, rec.getFname());
     cs.setString(3, rec.getLname());
     cs.setString(4, rec.getAgeRange());
     cs.setString(5, rec.getGender());
     cs.setString(6, rec.getEmail());
     cs.setString(7, rec.getPassword());
     cs.setString(8, rec.getCountry());
     cs.setString(9, rec.getUsertype());
     cs.setString(10, rec.getAccountStatus());
     int res = cs.executeUpdate();
     if (res > 0) {
       flag = rec;
     } else {
       flag = null;
     }
   } catch (Exception ex) {
     ex.printStackTrace();
   }
   return flag;
 }
 public void deleteSecGroup(CFSecurityAuthorization Authorization, CFSecuritySecGroupBuff Buff) {
   final String S_ProcName = "deleteSecGroup";
   Connection cnx = schema.getCnx();
   CallableStatement stmtDeleteByPKey = null;
   try {
     long ClusterId = Buff.getRequiredClusterId();
     int SecGroupId = Buff.getRequiredSecGroupId();
     stmtDeleteByPKey =
         cnx.prepareCall(
             "begin "
                 + schema.getLowerDbSchemaName()
                 + ".dl_secgrp( ?, ?, ?, ?, ?"
                 + ", "
                 + "?"
                 + ", "
                 + "?"
                 + ", "
                 + "?"
                 + " ); end;");
     int argIdx = 1;
     stmtDeleteByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtDeleteByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtDeleteByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtDeleteByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtDeleteByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtDeleteByPKey.setLong(argIdx++, ClusterId);
     stmtDeleteByPKey.setInt(argIdx++, SecGroupId);
     stmtDeleteByPKey.setInt(argIdx++, Buff.getRequiredRevision());
     ;
     stmtDeleteByPKey.execute();
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (stmtDeleteByPKey != null) {
       try {
         stmtDeleteByPKey.close();
       } catch (SQLException e) {
       }
       stmtDeleteByPKey = null;
     }
   }
 }
 public void setLong(String parameterName, long x) throws SQLException {
   checkOpen();
   try {
     _stmt.setLong(parameterName, x);
   } catch (SQLException e) {
     handleException(e);
   }
 }
 public void setLong(String parameterName, long x) throws SQLException {
   checkOpen();
   try {
     ((CallableStatement) _stmt).setLong(parameterName, x);
   } catch (SQLException e) {
     handleException(e);
   }
 }
Beispiel #14
0
  public List<String> invoiceCreatedAx(List<PanOrderLineDto> orderLines, String time)
      throws SQLException {
    List<String> createdInvoices = new ArrayList<String>();

    CallableStatement callableStatement = null;

    try {
      connection.setAutoCommit(false);

      callableStatement = connection.prepareCall(INVOICE_CREATED_AX_SQL);

      for (PanOrderLineDto orderLine : orderLines) {
        String invoiceNumber = "Bill-" + orderLine.getProgramId() + "-" + time;

        if (!createdInvoices.contains(invoiceNumber)) {
          createdInvoices.add(invoiceNumber);
        }

        callableStatement.registerOutParameter(1, Types.VARCHAR);

        callableStatement.setLong(2, orderLine.getId());
        callableStatement.setString(3, invoiceNumber);
        callableStatement.setLong(4, orderLine.getTDOrgId());
        callableStatement.setString(5, orderLine.getCurrencyId());
        callableStatement.setString(6, orderLine.getAgreementId());
        callableStatement.setString(7, orderLine.getRevenueType());

        callableStatement.execute();
      }

      connection.commit();

      return createdInvoices;
    } catch (SQLException e) {
      connection.rollback();

      throw e;
    } finally {
      if (callableStatement != null) {
        callableStatement.close();
      }

      connection.setAutoCommit(true);
    }
  }
  @Override
  public List<MotEmpConductor> findByCriterio(String criterio, String texto, Long empcodigoD)
      throws MotEmpConductorDaoException {

    Connection conn = null;
    CallableStatement stmt = null;
    ResultSet rs = null;

    List<MotEmpConductor> list = new ArrayList<MotEmpConductor>();
    try {
      conn = ResourceManager.getConnection();
      stmt = conn.prepareCall("{call SP_MOT_GET_LISTADO_CONDUCTORPORRITERIO;1(?,?,?)}");
      stmt.setString(1, criterio);
      stmt.setString(2, texto);
      stmt.setLong(3, empcodigoD);
      boolean results = stmt.execute();
      if (results) {
        rs = stmt.getResultSet();
        MotPersona persona = null;
        MotConductor conductor = null;
        MotEmpConductor empresaconductor = null; // ???

        while (rs.next()) {

          persona = new MotPersona();
          persona.setPernombresV(rs.getString("Nombres"));
          persona.setPerpaternoV(rs.getString("Paterno"));
          persona.setPermaternoV(rs.getString("Materno"));
          persona.setPerdniV(rs.getString("DNI"));

          conductor = new MotConductor();
          conductor.setConcodigoD(rs.getLong("CONDCODIGO"));
          conductor.setPersona(persona);

          empresaconductor = new MotEmpConductor();
          empresaconductor.setMotosasignadasI(rs.getInt("Motos Asignadas"));
          empresaconductor.setEcofechainicioF(rs.getString("Fecha Inicio"));
          empresaconductor.setEcofechaceseF(rs.getString("Fecha Cese"));
          empresaconductor.setConductor(conductor);
          list.add(empresaconductor);
        }
      }

    } catch (SQLException ex) {
      throw new MotEmpConductorDaoException(ex.getMessage());
    } finally {

      ResourceManager.close(rs);
      ResourceManager.close(stmt);
      ResourceManager.close(conn);
    }

    return list;
  }
 @Test
 public void testBadProcedureName() throws SQLException {
   CallableStatement cs = conn.prepareCall("{call Oopsy(?)}");
   cs.setLong(1, 99);
   try {
     cs.execute();
   } catch (SQLException e) {
     // Since it's a GENERAL_ERROR we need to look for a string by pattern.
     assertEquals(e.getSQLState(), SQLError.GENERAL_ERROR);
     assertTrue(Pattern.matches(".*Procedure .* not found.*", e.getMessage()));
   }
 }
Beispiel #17
0
  /** Sets the long */
  @Override
  public void setLong(String parameterName, long x) throws SQLException {
    try {
      _cstmt.setLong(parameterName, x);
    } catch (SQLException e) {
      onSqlException(e);

      throw e;
    } catch (RuntimeException e) {
      onRuntimeException(e);

      throw e;
    }
  }
 @Test
 public void testLostConnection() throws SQLException, ClassNotFoundException {
   // Break the current connection and try to execute a procedure call.
   CallableStatement cs = conn.prepareCall("{call Oopsy(?)}");
   stopServer();
   cs.setLong(1, 99);
   try {
     cs.execute();
   } catch (SQLException e) {
     assertEquals(e.getSQLState(), SQLError.CONNECTION_FAILURE);
   }
   // Restore a working connection for any remaining tests
   startServer();
 }
 public long getClass(long objectId) throws PersistenceException {
   try {
     CallableStatement callable;
     callable =
         this.con.prepareCall("Begin ? := " + this.schemaName + ".SrvcFacade.getClass(?); end;");
     callable.registerOutParameter(1, OracleTypes.NUMBER);
     callable.setLong(2, objectId);
     callable.execute();
     long result = callable.getLong(1);
     callable.close();
     return result;
   } catch (SQLException se) {
     throw new PersistenceException(se.getMessage(), se.getErrorCode());
   }
 }
  public long createGame(long gameCreator, String model, String filePath) {
    String sql = DatabaseProperties.getProperty("dominion.createGame");

    long gameId = 0;
    try (CallableStatement cs = con.prepareCall(sql)) {
      int index = 0;
      cs.setLong(++index, gameCreator);
      cs.setString(++index, model);
      cs.setString(++index, filePath);
      cs.execute();
      filePath = cs.getString(3);
      gameId = cs.getLong(4);
    } catch (Exception e) {
      log.log(Level.WARNING, "Error adding user", e);
    }
    return gameId;
  }
 public Map<String, String> updateTask(String taskStatus) {
   Map<String, String> resultMap = new HashMap<String, String>();
   String status = "E";
   String message = null;
   XxntcCsCalendarActivitiesEOVOImpl vo = getXxntcCsCalendarActivitiesEOVO2Update();
   Row row = vo.getCurrentRow();
   Date startTime = (Date) row.getAttribute("StartTime");
   Date endTime = (Date) row.getAttribute("EndTime");
   Number incidentId = (Number) row.getAttribute("IncidentId");
   Number resourceId = (Number) row.getAttribute("ResourceId");
   _logger.warning("Before Calling API");
   _logger.warning("taskStatus:" + taskStatus.toString());
   _logger.warning("startTime:" + startTime.toString());
   _logger.warning("endTime:" + endTime.toString());
   _logger.warning("incidentId:" + incidentId.toString());
   _logger.warning("resourceId:" + resourceId.toString());
   CallableStatement cs = null;
   String statement = "BEGIN XXNTC_CALENDAR_PKG.SCHEDULE_SR_PRC(?, ?, ?, ?, ?, ?, ?); END;";
   try {
     cs = getDBTransaction().createCallableStatement(statement, 0);
     cs.registerOutParameter(6, Types.VARCHAR);
     cs.registerOutParameter(7, Types.VARCHAR);
     cs.setString(1, taskStatus);
     cs.setDate(2, startTime.dateValue());
     cs.setDate(3, endTime.dateValue());
     cs.setInt(4, incidentId.intValue());
     cs.setLong(5, resourceId.longValue());
     cs.executeUpdate();
     status = cs.getString(6);
     message = cs.getString(7);
   } catch (SQLException e) {
     _logger.severe("Sql Exception during statement call", e);
   } finally {
     try {
       if (cs != null) cs.close();
     } catch (SQLException e) {
       _logger.severe("Sql Exception While Closing Callable Statement", e);
     }
   }
   resultMap.put("x_status", status);
   resultMap.put("x_error_message", message);
   _logger.warning("After API is called");
   _logger.warning("x_status:" + status);
   _logger.warning("x_error_message:" + message);
   return resultMap;
 }
 @Override
 public void modificar(MotInteInventario inteInventario) throws MotInteInventarioDaoException {
   Connection conn = null;
   CallableStatement stmt = null;
   try {
     conn = ResourceManager.getConnection();
     stmt = conn.prepareCall("{call SP_MOT_UPD_INTE_INVENTARIO;1(?,?,?,?)}");
     stmt.setLong(1, inteInventario.getInternamiento().getIntcodigoD());
     stmt.setInt(2, inteInventario.getInventarioTipo().getBitcodigoI());
     stmt.setString(3, inteInventario.getBivestadoC());
     stmt.setInt(4, inteInventario.getBivcantidadI());
     stmt.execute();
   } catch (SQLException e) {
     throw new MotInteInventarioDaoException(e.getMessage(), e);
   } finally {
     ResourceManager.close(stmt);
     ResourceManager.close(conn);
   }
 }
Beispiel #23
0
  public String setInvoiceStatus(String invoiceNumber, InvoiceStatusType invoiceStatus)
      throws SQLException {
    CallableStatement callableStatement = null;

    try {
      callableStatement = connection.prepareCall(UPDATE_INVOICE_STATUS_SQL);

      callableStatement.registerOutParameter(1, Types.VARCHAR);

      callableStatement.setString(2, invoiceNumber);
      callableStatement.setLong(3, invoiceStatus.getId());

      callableStatement.execute();

      return callableStatement.getString(1);
    } finally {
      if (callableStatement != null) {
        callableStatement.close();
      }
    }
  }
 @Override
 public void insertar(MotInteInventario inteInventario) throws MotInteInventarioDaoException {
   Connection conn = null;
   CallableStatement stmt = null;
   try {
     conn = ResourceManager.getConnection();
     stmt = conn.prepareCall("{call SP_MOT_INS_INTE_INVENTARIO;1(?,?,?,?,?)}");
     stmt.registerOutParameter(1, Types.DECIMAL);
     stmt.setLong(2, inteInventario.getInternamiento().getIntcodigoD());
     stmt.setInt(3, inteInventario.getInventarioTipo().getBitcodigoI());
     stmt.setString(4, inteInventario.getBivestadoC());
     stmt.setInt(5, inteInventario.getBivcantidadI());
     stmt.execute();
     Long codigo = stmt.getLong(1);
     if (codigo != null) {
       inteInventario.setBivcodigoD(codigo);
     }
   } catch (SQLException e) {
     throw new MotInteInventarioDaoException(e.getMessage(), e);
   } finally {
     ResourceManager.close(stmt);
     ResourceManager.close(conn);
   }
 }
 public void updateAuditAction(
     CFSecurityAuthorization Authorization, CFSecurityAuditActionBuff Buff) {
   final String S_ProcName = "updateAuditAction";
   ResultSet resultSet = null;
   Connection cnx = schema.getCnx();
   CallableStatement stmtUpdateByPKey = null;
   List<CFSecurityAuditActionBuff> buffList = new LinkedList<CFSecurityAuditActionBuff>();
   try {
     ICFSecuritySchema.AuditActionEnum AuditActionId = Buff.getRequiredAuditActionId();
     String Description = Buff.getRequiredDescription();
     int Revision = Buff.getRequiredRevision();
     stmtUpdateByPKey =
         cnx.prepareCall(
             "begin "
                 + schema.getLowerDbSchemaName()
                 + ".upd_auditaction( ?, ?, ?, ?, ?, ?, ?"
                 + ", "
                 + "?"
                 + ", "
                 + "?"
                 + ", "
                 + "? ); end;");
     int argIdx = 1;
     stmtUpdateByPKey.registerOutParameter(argIdx++, OracleTypes.CURSOR);
     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++, "AUDT");
     stmtUpdateByPKey.setShort(argIdx++, (short) AuditActionId.ordinal());
     stmtUpdateByPKey.setString(argIdx++, Description);
     stmtUpdateByPKey.setInt(argIdx++, Revision);
     stmtUpdateByPKey.execute();
     resultSet = (ResultSet) stmtUpdateByPKey.getObject(1);
     if (resultSet != null) {
       try {
         if (resultSet.next()) {
           CFSecurityAuditActionBuff updatedBuff = unpackAuditActionResultSetToBuff(resultSet);
           if (resultSet.next()) {
             resultSet.last();
             throw CFLib.getDefaultExceptionFactory()
                 .newRuntimeException(
                     getClass(),
                     S_ProcName,
                     "Did not expect multi-record response, "
                         + resultSet.getRow()
                         + " rows selected");
           }
           Buff.setRequiredDescription(updatedBuff.getRequiredDescription());
           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()
             .newRuntimeException(
                 getClass(), S_ProcName, "upd_auditaction() did not return a valid result cursor");
       } finally {
         if (resultSet != null) {
           try {
             resultSet.close();
           } catch (SQLException e) {
           }
           resultSet = null;
         }
       }
     } else {
       throw CFLib.getDefaultExceptionFactory()
           .newRuntimeException(
               getClass(), S_ProcName, "upd_auditaction() did not return a result cursor");
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
     if (stmtUpdateByPKey != null) {
       try {
         stmtUpdateByPKey.close();
       } catch (SQLException e) {
       }
       stmtUpdateByPKey = null;
     }
   }
 }
 public CFSecurityAuditActionBuff readBuffByUDescrIdx(
     CFSecurityAuthorization Authorization, String Description) {
   final String S_ProcName = "readBuffByUDescrIdx";
   ResultSet resultSet = null;
   Connection cnx = schema.getCnx();
   CallableStatement stmtReadBuffByUDescrIdx = null;
   try {
     stmtReadBuffByUDescrIdx =
         cnx.prepareCall(
             "begin "
                 + schema.getLowerDbSchemaName()
                 + ".rd_auditactionbyudescridx( ?, ?, ?, ?, ?, ?"
                 + ", "
                 + "?"
                 + " ); end;");
     int argIdx = 1;
     stmtReadBuffByUDescrIdx.registerOutParameter(argIdx++, OracleTypes.CURSOR);
     stmtReadBuffByUDescrIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadBuffByUDescrIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtReadBuffByUDescrIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtReadBuffByUDescrIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadBuffByUDescrIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtReadBuffByUDescrIdx.setString(argIdx++, Description);
     stmtReadBuffByUDescrIdx.execute();
     resultSet = (ResultSet) stmtReadBuffByUDescrIdx.getObject(1);
     if (resultSet == null) {
       return (null);
     }
     try {
       if (resultSet.next()) {
         CFSecurityAuditActionBuff buff = unpackAuditActionResultSetToBuff(resultSet);
         if (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) {
       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;
     }
     if (stmtReadBuffByUDescrIdx != null) {
       try {
         stmtReadBuffByUDescrIdx.close();
       } catch (SQLException e) {
       }
       stmtReadBuffByUDescrIdx = null;
     }
   }
 }
 public CFSecurityAuditActionBuff[] readAllBuff(CFSecurityAuthorization Authorization) {
   final String S_ProcName = "readAllBuff";
   if (!schema.isTransactionOpen()) {
     throw CFLib.getDefaultExceptionFactory()
         .newUsageException(getClass(), S_ProcName, "Transaction not open");
   }
   ResultSet resultSet = null;
   Connection cnx = schema.getCnx();
   CallableStatement stmtReadAllBuff = null;
   try {
     CFSecurityAuditActionBuff buff = null;
     List<CFSecurityAuditActionBuff> buffList = new LinkedList<CFSecurityAuditActionBuff>();
     stmtReadAllBuff =
         cnx.prepareCall(
             "begin "
                 + schema.getLowerDbSchemaName()
                 + ".rd_auditactionall( ?, ?, ?, ?, ?, ? ) ); end;");
     int argIdx = 1;
     stmtReadAllBuff.registerOutParameter(argIdx++, OracleTypes.CURSOR);
     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());
     stmtReadAllBuff.execute();
     resultSet = (ResultSet) stmtReadAllBuff.getObject(1);
     if (resultSet != null) {
       try {
         while (resultSet.next()) {
           buff = unpackAuditActionResultSetToBuff(resultSet);
           buffList.add(buff);
         }
       } catch (SQLException e) {
         // Oracle may return an invalid resultSet if the rowset is empty
       }
     }
     int idx = 0;
     CFSecurityAuditActionBuff[] retBuff = new CFSecurityAuditActionBuff[buffList.size()];
     Iterator<CFSecurityAuditActionBuff> 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;
     }
     if (stmtReadAllBuff != null) {
       try {
         stmtReadAllBuff.close();
       } catch (SQLException e) {
       }
       stmtReadAllBuff = null;
     }
   }
 }
  public CFSecurityAuditActionBuff lockBuff(
      CFSecurityAuthorization Authorization, CFSecurityAuditActionPKey PKey) {
    final String S_ProcName = "lockBuff";
    if (!schema.isTransactionOpen()) {
      throw CFLib.getDefaultExceptionFactory()
          .newUsageException(getClass(), S_ProcName, "Transaction not open");
    }
    ResultSet resultSet = null;
    Connection cnx = schema.getCnx();
    CallableStatement stmtLockBuffByPKey = null;
    try {
      ICFSecuritySchema.AuditActionEnum AuditActionId = PKey.getRequiredAuditActionId();

      stmtLockBuffByPKey =
          cnx.prepareCall(
              "begin "
                  + schema.getLowerDbSchemaName()
                  + ".lck_auditaction( ?, ?, ?, ?, ?, ?"
                  + ", "
                  + "?"
                  + " ); end;");
      int argIdx = 1;
      stmtLockBuffByPKey.registerOutParameter(argIdx++, OracleTypes.CURSOR);
      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++, (short) AuditActionId.ordinal());
      stmtLockBuffByPKey.execute();
      resultSet = (ResultSet) stmtLockBuffByPKey.getObject(1);
      if (resultSet == null) {
        return (null);
      }
      try {
        if (resultSet.next()) {
          CFSecurityAuditActionBuff buff = unpackAuditActionResultSetToBuff(resultSet);
          if (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) {
        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;
      }
      if (stmtLockBuffByPKey != null) {
        try {
          stmtLockBuffByPKey.close();
        } catch (SQLException e) {
        }
        stmtLockBuffByPKey = null;
      }
    }
  }
 public CFSecuritySecGroupBuff[] readBuffByClusterIdx(
     CFSecurityAuthorization Authorization, long ClusterId) {
   final String S_ProcName = "readBuffByClusterIdx";
   ResultSet resultSet = null;
   Connection cnx = schema.getCnx();
   CallableStatement stmtReadBuffByClusterIdx = null;
   List<CFSecuritySecGroupBuff> buffList = new LinkedList<CFSecuritySecGroupBuff>();
   try {
     stmtReadBuffByClusterIdx =
         cnx.prepareCall(
             "begin "
                 + schema.getLowerDbSchemaName()
                 + ".rd_secgrpbyclusteridx( ?, ?, ?, ?, ?, ?"
                 + ", "
                 + "?"
                 + " ); end;");
     int argIdx = 1;
     stmtReadBuffByClusterIdx.registerOutParameter(argIdx++, OracleTypes.CURSOR);
     stmtReadBuffByClusterIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadBuffByClusterIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtReadBuffByClusterIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtReadBuffByClusterIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadBuffByClusterIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtReadBuffByClusterIdx.setLong(argIdx++, ClusterId);
     stmtReadBuffByClusterIdx.execute();
     resultSet = (ResultSet) stmtReadBuffByClusterIdx.getObject(1);
     if (resultSet != null) {
       try {
         while (resultSet.next()) {
           CFSecuritySecGroupBuff buff = unpackSecGroupResultSetToBuff(resultSet);
           buffList.add(buff);
         }
         try {
           resultSet.close();
         } catch (SQLException e) {
         }
         resultSet = null;
       } catch (SQLException e) {
       }
     }
     int idx = 0;
     CFSecuritySecGroupBuff[] retBuff = new CFSecuritySecGroupBuff[buffList.size()];
     Iterator<CFSecuritySecGroupBuff> 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;
     }
     if (stmtReadBuffByClusterIdx != null) {
       try {
         stmtReadBuffByClusterIdx.close();
       } catch (SQLException e) {
       }
       stmtReadBuffByClusterIdx = null;
     }
   }
 }
 public void createSecGroup(CFSecurityAuthorization Authorization, CFSecuritySecGroupBuff Buff) {
   final String S_ProcName = "createSecGroup";
   if (!schema.isTransactionOpen()) {
     throw CFLib.getDefaultExceptionFactory()
         .newUsageException(getClass(), S_ProcName, "Transaction not open");
   }
   ResultSet resultSet = null;
   CallableStatement stmtCreateByPKey = null;
   try {
     long ClusterId = Buff.getRequiredClusterId();
     String Name = Buff.getRequiredName();
     Connection cnx = schema.getCnx();
     stmtCreateByPKey =
         cnx.prepareCall(
             "begin "
                 + schema.getLowerDbSchemaName()
                 + ".crt_secgrp( ?, ?, ?, ?, ?, ?, ?"
                 + ", "
                 + "?"
                 + ", "
                 + "?"
                 + " ); end;");
     int argIdx = 1;
     stmtCreateByPKey.registerOutParameter(argIdx++, OracleTypes.CURSOR);
     stmtCreateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     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++, "SGRP");
     stmtCreateByPKey.setLong(argIdx++, ClusterId);
     stmtCreateByPKey.setString(argIdx++, Name);
     stmtCreateByPKey.execute();
     resultSet = (ResultSet) stmtCreateByPKey.getObject(1);
     if (resultSet == null) {
       throw CFLib.getDefaultExceptionFactory()
           .newRuntimeException(
               getClass(), S_ProcName, "crt_secgrp() did not return a result set");
     }
     try {
       if (resultSet.next()) {
         CFSecuritySecGroupBuff createdBuff = unpackSecGroupResultSetToBuff(resultSet);
         if (resultSet.next()) {
           resultSet.last();
           throw CFLib.getDefaultExceptionFactory()
               .newRuntimeException(
                   getClass(),
                   S_ProcName,
                   "Did not expect multi-record response, "
                       + resultSet.getRow()
                       + " rows selected");
         }
         Buff.setRequiredClusterId(createdBuff.getRequiredClusterId());
         Buff.setRequiredSecGroupId(createdBuff.getRequiredSecGroupId());
         Buff.setRequiredName(createdBuff.getRequiredName());
         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()
           .newRuntimeException(
               getClass(), S_ProcName, "crt_secgrp() did not return a valid result set");
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
     if (stmtCreateByPKey != null) {
       try {
         stmtCreateByPKey.close();
       } catch (SQLException e) {
       }
       stmtCreateByPKey = null;
     }
   }
 }