コード例 #1
1
 public ArrayList<DetalleFactura> buscar(Factura entidad) throws Exception {
   ArrayList<DetalleFactura> lista = new ArrayList<DetalleFactura>();
   try {
     cnn = Conexion.getConexion();
     CallableStatement cs = null;
     cs = cnn.prepareCall("call uspListDetalleFactrua(?)");
     cs.setInt(1, entidad.getIdFactura());
     rs = cs.executeQuery();
     while (rs.next()) {
       DetalleFactura objeto = new DetalleFactura();
       objeto.setIdDetalleFactura(rs.getInt("Iddetallefactura"));
       objeto.setIdProducto(rs.getInt("Idproducto"));
       objeto.setCantidad(rs.getInt("Cantidad"));
       objeto.setPrecio(rs.getDouble("Precio"));
       objeto.setSubTotal(rs.getDouble("Subtotal"));
       objeto.setIdFactura(rs.getInt("Idfactura"));
       objeto.setDProducto(rs.getString("DProducto"));
       lista.add(objeto);
     }
     cnn.close();
     cs.close();
   } catch (SQLException ex) {
     throw ex;
   }
   return lista;
 }
コード例 #2
0
  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");
    }
  }
コード例 #3
0
  private void suivantButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_suivantButtonActionPerformed

    pNumber++;
    pageNumberLabel.setText(Integer.toString(pNumber));

    GUI container = (GUI) SwingUtilities.getWindowAncestor(this); // on prend son grand pere
    CallableStatement cs = null;
    Connection conDB = container.getBeanbd().getConnexion();
    ResultSet rs = null;

    avisArea.setText("");

    try {
      cs = conDB.prepareCall("{? = call PACKAGERECHERCHE.getAvisFilm(?, ?)}");
      cs.registerOutParameter(1, OracleTypes.CURSOR);
      cs.setInt(2, filmID);
      cs.setInt(3, pNumber);
      cs.executeQuery();
      rs = (ResultSet) cs.getObject(1);

      while (rs.next()) {
        avisArea.append("User : "******"\n");
        avisArea.append("Avis : " + rs.getString(2) + "\n\n");
        avisArea.append("---------------------------------\n\n");
      }

    } catch (SQLException ex) {
      System.err.println("err " + ex);
    }
  } // GEN-LAST:event_suivantButtonActionPerformed
コード例 #4
0
ファイル: ClientDAO.java プロジェクト: naveenkumarm/mySamples
 public List<ClientListInfo> getClientsDataTable(
     int startRecord, int recordsToShow, String clientNameKey) {
   try {
     Session session = sessionFactory.getCurrentSession();
     CallableStatement cstmt =
         session.connection().prepareCall("{call ADMIN_CLIENT_MANAGEMENT(?,?,?)}");
     List<ClientListInfo> clientListInfo = new ArrayList<ClientListInfo>();
     cstmt.setInt(1, startRecord);
     cstmt.setInt(2, recordsToShow);
     cstmt.setString(3, clientNameKey.trim());
     ResultSet rs = cstmt.executeQuery();
     if (rs != null) {
       while (rs.next()) {
         ClientListInfo clientInfo = new ClientListInfo();
         clientInfo.setIndex(rs.getInt(1));
         clientInfo.setClientId(rs.getInt(2));
         clientInfo.setClientName(rs.getString(3));
         clientInfo.setBusinessType(rs.getString(4));
         clientInfo.setContactPerson(rs.getString(5));
         clientInfo.setWorkPhone(rs.getString(6));
         clientInfo.setMobileNumber(rs.getString(7));
         clientInfo.setIsActive(rs.getBoolean(9));
         clientInfo.setEdit(rs.getInt(2));
         clientInfo.setDelete(rs.getInt(2));
         clientInfo.setTotalRows(rs.getInt(10));
         clientListInfo.add(clientInfo);
       }
     }
     return clientListInfo;
   } catch (Exception e) {
     log.error("Exception in get Client Data Table : DAO :" + ExceptionUtils.getStackTrace(e));
   }
   return null;
 }
コード例 #5
0
 public String getGarageFromResp(
     String profile, Integer userId, Integer respId, Integer respApplId) {
   String garage = null;
   CallableStatement cs = null;
   String statement = "BEGIN ? := FND_PROFILE.VALUE_SPECIFIC(?, ?, ?, ?); END;";
   try {
     cs = getDBTransaction().createCallableStatement(statement, 0);
     cs.registerOutParameter(1, Types.VARCHAR);
     cs.setString(2, profile);
     cs.setInt(3, userId.intValue());
     cs.setInt(4, respId.intValue());
     cs.setInt(5, respApplId.intValue());
     cs.executeUpdate();
     garage = cs.getString(1);
   } catch (SQLException e) {
     _logger.severe("SQL Exception setGarageFromResp", e);
   } finally {
     try {
       if (cs != null) {
         cs.close();
       }
     } catch (SQLException e) {
       _logger.severe("SQL Exception setGarageFromResp", e);
     }
   }
   return garage;
 }
コード例 #6
0
  @Override
  public String lecturas(int periodo, int borrar) {
    try {
      Connection con = dao.getConnection();

      String sql = "{call P_INT_LECTURAS(?,?,?)}";
      CallableStatement statement = con.prepareCall(sql);

      statement.setInt(1, periodo);

      statement.setInt(2, borrar); // preguntar a javier

      statement.registerOutParameter(3, Types.VARCHAR);

      statement.executeQuery();

      String error = statement.getString(3);
      con.close();
      return error;

    } catch (SQLException ex) {
      ex.printStackTrace();
      Logger.getLogger(InterfazManagerImpl.class.getName()).log(Level.SEVERE, null, ex);
      return "Error al ejecutar en la BD";
    }
  }
コード例 #7
0
  @Override
  public int save(java.sql.Connection connection) {
    int i = 0;
    int nParam = 1;
    CallableStatement callableStatement = null;

    mnLastDbActionResult = SLibConstants.UNDEFINED;

    try {
      callableStatement =
          connection.prepareCall("{ CALL mfgu_line_save(" + "?, ?, ?, ?, ?, " + "?, ?, ?) }");
      callableStatement.setInt(nParam++, mnPkMfgLineId);
      callableStatement.setString(nParam++, msMfgLine);
      callableStatement.setBoolean(nParam++, mbIsDeleted);
      callableStatement.setInt(nParam++, mnFkCostCenterId);
      callableStatement.setInt(nParam++, mbIsRegistryNew ? mnFkUserNewId : mnFkUserEditId);
      callableStatement.registerOutParameter(nParam++, java.sql.Types.INTEGER);
      callableStatement.registerOutParameter(nParam++, java.sql.Types.SMALLINT);
      callableStatement.registerOutParameter(nParam++, java.sql.Types.VARCHAR);
      callableStatement.execute();

      mnPkMfgLineId = callableStatement.getInt(nParam - 3);
      mnDbmsErrorId = callableStatement.getInt(nParam - 2);
      msDbmsError = callableStatement.getString(nParam - 1);

      mbIsRegistryNew = false;
      mnLastDbActionResult = SLibConstants.DB_ACTION_SAVE_OK;
    } catch (java.lang.Exception e) {
      mnLastDbActionResult = SLibConstants.DB_ACTION_SAVE_ERROR;
      SLibUtilities.printOutException(this, e);
    }

    return mnLastDbActionResult;
  }
コード例 #8
0
ファイル: VentaDao.java プロジェクト: brenda-caz/rubius
  public static int insertarVenta(Venta v) {
    ConnectionPool pool = ConnectionPool.getInstance();
    Connection connection = pool.getConnection();
    CallableStatement cs = null;
    ResultSet rs = null;
    Venta ven = null;
    try {
      cs = connection.prepareCall("{ call insertVenta(?, ?, ?, ?) }");
      cs.setInt(1, v.getUsuarioVenta().getId());
      cs.setDouble(2, v.getSubtotal());
      cs.setInt(3, v.getPagoVenta().getIdPago());
      cs.setInt(4, v.getUsuarioVenta().getSucursal().getIdSucursal());

      rs = cs.executeQuery();
      while (rs.next()) {
        ven = new Venta(rs.getInt("idVenta"));
      }

      return ven.getIdVenta();

    } catch (Exception ex) {
      ex.printStackTrace();
      return 0;

    } finally {
      DBUtil.closeStatement(cs);
      pool.freeConnection(connection);
    }
  }
コード例 #9
0
 public boolean cambiarEstado(orgen_ta_subdependencia obj, String idUsu) {
   boolean exito = false;
   try {
     cn = ds.getConnection();
     cn.setAutoCommit(false);
     String sql = "{ CALL SP_ORGEN_TA_SUBDEPENDENCIA_ELI(?,?,?) }";
     CallableStatement cstm = cn.prepareCall(sql);
     cstm.setInt("P_IN_CODIGO_SUBDEPENDENCIA", obj.getIn_codigo_subdependencia());
     cstm.setString("P_CH_ESTADO", obj.getCh_estado());
     cstm.setInt("P_IN_CODIGO_USUARIO", Integer.parseInt(idUsu));
     cstm.executeUpdate();
     cn.commit();
     cstm.close();
     exito = true;
   } catch (Exception e) {
     exito = false;
     System.out.println("Failed to execute a JDBC task: " + e);
   } finally {
     try {
       cn.close();
     } catch (Exception ex) {
       System.out.println("finally - Failed to finalize JDBC task: " + ex);
     }
   }
   return exito;
 }
コード例 #10
0
 @SuppressWarnings("deprecation")
 protected void spSalFactD(Map params) {
   try {
     Connection conn = getSession().connection();
     CallableStatement cs =
         conn.prepareCall("{call SP_HRSAL_FACTDT(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)}");
     int branchId = ((Integer) params.get("branch.id")).intValue();
     String hdNo = (String) params.get("fact.no");
     int no = ((Integer) params.get("no")).intValue();
     int itemId = ((Integer) params.get("item.id")).intValue();
     int departId = ((Integer) params.get("depart.id")).intValue();
     int personId = ((Integer) params.get("person.id")).intValue();
     double amount = ((Double) params.get("amount")).doubleValue();
     Date date = new Date(ObjectUtil.toCalendar(params.get("date")).getTimeInMillis());
     String workerId = (String) params.get("person.workerId");
     String type = (String) params.get("type");
     int index = 1;
     cs.setInt(index++, branchId);
     cs.setString(index++, hdNo);
     cs.setInt(index++, no);
     cs.setInt(index++, itemId);
     cs.setInt(index++, departId);
     cs.setInt(index++, personId);
     cs.setDouble(index++, amount);
     cs.setDate(index++, date);
     cs.setString(index++, workerId);
     cs.setString(index++, type);
     cs.execute();
   } catch (Exception e) {
     throw new HibernateException(e);
   }
 }
コード例 #11
0
  @Override
  public int call(java.sql.Connection connection) {
    int nParam = 1;
    java.sql.CallableStatement callableStatement = null;

    mnLastDbActionResult = SLibConstants.UNDEFINED;

    try {
      callableStatement = connection.prepareCall("{ CALL mfg_ltime_cob_val(?, ?, ?) }");
      callableStatement.setInt(nParam, (Integer) mvParamsIn.get(nParam - 1));
      nParam++;
      callableStatement.setInt(nParam, (Integer) mvParamsIn.get(nParam - 1));
      nParam++;
      callableStatement.registerOutParameter(nParam, java.sql.Types.INTEGER);
      callableStatement.execute();

      mvParamsOut.clear();
      mvParamsOut.add(callableStatement.getInt(nParam));
      mnLastDbActionResult = SLibConstants.DB_PROCEDURE_OK;
    } catch (java.sql.SQLException e) {
      mnLastDbActionResult = SLibConstants.DB_PROCEDURE_ERROR;
      SLibUtilities.printOutException(this, e);
    } catch (java.lang.Exception e) {
      mnLastDbActionResult = SLibConstants.DB_PROCEDURE_ERROR;
      SLibUtilities.printOutException(this, e);
    }

    return mnLastDbActionResult;
  }
コード例 #12
0
ファイル: BDAlquiler.java プロジェクト: jalcantara/Comision
  public boolean insertarAlquiler(
      int idtrabajador,
      int idCliente,
      ArrayList<Detalle_Alquiler> lista_detalle,
      int identificador) {
    boolean resultado = false;
    Connection cnn = null;
    CallableStatement cstmt = null;
    CallableStatement cstm1 = null;
    CallableStatement cstm2 = null;
    int id_alquiler = 0;
    try {
      cnn = BD.getConnection();
      cnn.setAutoCommit(false);
      String sql = "call spI_Alquiler (?,?,?,?);";
      cstmt = cnn.prepareCall(sql);
      cstmt.setInt(1, 2);
      cstmt.setInt(2, idCliente);
      cstmt.setInt(3, idtrabajador);
      cstmt.setInt(4, identificador);
      ResultSet rs = cstmt.executeQuery();
      if (rs.next()) {
        id_alquiler = rs.getInt("int_id");
      }
      for (int i = 0; i < lista_detalle.size(); i++) {
        String sql1 = "call spI_DetalleAlquiler(?,?,?,?,?,?,?);";
        cstm1 = cnn.prepareCall(sql1);
        cstm1.setInt(1, id_alquiler);
        cstm1.setInt(2, lista_detalle.get(i).getMaterial_id());
        cstm1.setInt(3, lista_detalle.get(i).getInt_cantidad());
        cstm1.setDouble(4, lista_detalle.get(i).getDec_monto());
        cstm1.setTimestamp(5, lista_detalle.get(i).getDat_fechfin());
        cstm1.setTimestamp(6, lista_detalle.get(i).getDat_fechinicio());
        cstm1.setInt(7, lista_detalle.get(i).getInt_horas());
        cstm1.execute();
      }
      // Registrar Pagos
      String sql2 = "call spI_Pagos_ByAlquiler(?,?);";
      cstm2 = cnn.prepareCall(sql2);
      cstm2.setInt(1, 1); // es el codigo del usuario cambiar despues
      cstm2.setInt(2, id_alquiler);
      cstm2.execute();

      cnn.commit();
      resultado = true;
    } catch (SQLException s) {
      try {
        cnn.rollback();
      } catch (SQLException b) {
      }
      System.out.println("aquí es :/ " + s);
    } finally {
      try {
        cstmt.close();
        cnn.close();
      } catch (SQLException ex) {
      }
    }
    return resultado;
  }
コード例 #13
0
ファイル: GuiaDAO.java プロジェクト: Truexxangusxx/empbus
 public void editar(Guia objeto, Usuario usuario, String xml) throws Exception {
   try {
     cnn = Conexion.getConexion();
     CallableStatement cs = null;
     cs = cnn.prepareCall("call uspUpdGuia(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
     cs.setInt(1, objeto.getIdGuia());
     cs.setString(2, objeto.getPeriodo());
     cs.setString(3, objeto.getNumero());
     cs.setString(4, objeto.getFecha());
     cs.setDouble(5, objeto.getTipoCambio());
     cs.setString(6, objeto.getSerie());
     cs.setString(7, objeto.getNumeroDocumento());
     cs.setInt(8, objeto.getIdTipoMovimiento());
     cs.setString(9, objeto.getReferencia());
     cs.setInt(10, objeto.getIdOrdenProduccion());
     cs.setInt(11, objeto.getIdClienteProveedor());
     cs.setInt(12, objeto.getIdAlmacen());
     cs.setString(13, objeto.getObservaciones());
     cs.setString(14, usuario.getNick());
     cs.setString(15, xml);
     cs.execute();
     cnn.close();
     cs.close();
   } catch (SQLException ex) {
     throw ex;
   }
 }
コード例 #14
0
  @Override
  public void registrarPersonaDireccion(
      int idPersona, int idTipoPersona, int idDireccion, Connection conexion) throws SQLException {
    CallableStatement cs = null;
    String sql = "{ ? = call negocio.fn_ingresarpersonadireccion(?,?,?) }";

    try {
      cs = conexion.prepareCall(sql);
      int i = 1;
      cs.registerOutParameter(i++, Types.BOOLEAN);
      cs.setInt(i++, idPersona);
      cs.setInt(i++, idTipoPersona);
      cs.setInt(i++, idDireccion);

      cs.execute();
    } catch (SQLException e) {
      throw new SQLException(e);
    } finally {
      try {
        if (cs != null) {
          cs.close();
        }
      } catch (SQLException e) {
        throw new SQLException(e);
      }
    }
  }
コード例 #15
0
ファイル: ConnDB.java プロジェクト: CaikeBispo/testeOrange
  public void cadastrarProduto(
      String descricaoProduto,
      int precoCusto,
      int precoVenda,
      int quantidade,
      String refImagem,
      String produto)
      throws ClassNotFoundException, SQLException {

    try {

      abrirConexaoProperties();

      CallableStatement cs = conexao.prepareCall("{ call inserir_produto(?,?,?,?,?,?) }");
      // PARÂMETROS PARA A PROCEDURE
      cs.setString(1, descricaoProduto);
      cs.setInt(2, precoCusto);
      cs.setInt(3, precoVenda);
      cs.setInt(4, quantidade);
      cs.setString(5, refImagem);
      cs.setString(6, produto);

      // EXECUÇÃO DA PROCEDURE
      cs.execute();

    } catch (SQLException ex) {
      JOptionPane.showMessageDialog(null, "Erro: " + ex.toString());
    } finally {
      fecharConexao();
    }
  }
コード例 #16
0
 public boolean guardarSubDependencia(
     orgen_ta_subdependencia obj, String nomUsuario, int idUsuario) {
   boolean estado = false;
   try {
     cn = ds.getConnection();
     cn.setAutoCommit(false);
     String sql = "{ CALL SP_ORGEN_TA_SUBDEPENDENCIA_INS(?,?,?,?,?) }";
     CallableStatement cstm = cn.prepareCall(sql);
     cstm.setString("P_VC_NOMBRE", obj.getVc_nombre().toUpperCase());
     cstm.setString("P_VC_DESCRIPCION", obj.getVc_descripcion().toUpperCase());
     cstm.setString("P_VC_USUARIO_CREA", nomUsuario);
     cstm.setInt("P_IN_CODIGO_USUARIO", idUsuario);
     cstm.setInt("P_IN_CODIGO_DEP", obj.getIn_codigo_dependecia());
     cstm.executeUpdate();
     cn.commit();
     estado = true;
     cstm.close();
   } catch (Exception e) {
     System.out.println("Failed to execute a JDBC task: " + e);
     estado = false;
   } finally {
     try {
       cn.close();
     } catch (Exception ex) {
       System.out.println("finally - Failed to finalize JDBC task: " + ex);
     }
     return estado;
   }
 }
コード例 #17
0
 /**
  * Control de transacción en el procedimiento almacenado
  *
  * @param prod
  */
 @Override
 public void create2(Producto prod) {
   Connection cn = null;
   try {
     cn = AccesoDB.getConnection();
     cn.setAutoCommit(true);
     String query = "{call usp_crea_producto(?,?,?,?,?)}";
     CallableStatement cstm = cn.prepareCall(query);
     cstm.registerOutParameter(1, Types.INTEGER);
     cstm.setInt(2, prod.getIdcat());
     cstm.setString(3, prod.getNombre());
     cstm.setDouble(4, prod.getPrecio());
     cstm.setInt(5, prod.getStock());
     cstm.executeUpdate();
     prod.setIdprod(cstm.getInt(1));
     cstm.close();
   } catch (SQLException e) {
     throw new RuntimeException(e.getMessage());
   } catch (Exception e) {
     throw new RuntimeException("No se puede crear el producto.");
   } finally {
     try {
       cn.close();
     } catch (Exception e) {
     }
   }
 }
コード例 #18
0
ファイル: DbManager.java プロジェクト: IFT-SE/recommender
 /**
  * Inserts a new mapping from method id to word id to the methods_words table of the database.
  * Each row represents one instance of a word existing in the method. Unlike the other inserts,
  * duplicate entries are allowed since each word can exist more than once in a method.
  *
  * @param methodId The method's database ID
  * @param wordId The word's ID
  */
 public void insertMethodToWordMapping(int methodId, int wordId) {
   try {
     sp_insertMethodToWordMapping.setInt(1, methodId);
     sp_insertMethodToWordMapping.setInt(2, wordId);
     sp_insertMethodToWordMapping.executeUpdate();
   } catch (SQLException e) {
     eLog.logException(e);
   }
 }
コード例 #19
0
ファイル: PublicacionesDAO.java プロジェクト: eightd/SICVA
  public String guardarDato(PublicacionesDTO asistenciacursosDTO) {
    try {
      try {
        ConexionBD conexionBD = new ConexionBD();
        conexionBD.abrir();
        Connection connection = conexionBD.getConexion();

        String sql = "{ ? = call insertar_publicaciones(?,?,?,?,?,?,?,?)} ";

        CallableStatement callableStatement = connection.prepareCall(sql);
        callableStatement.registerOutParameter(1, Types.INTEGER);
        callableStatement.setString(2, asistenciacursosDTO.getPeriodo());
        callableStatement.setString(3, asistenciacursosDTO.getPublicacion());
        callableStatement.setString(4, asistenciacursosDTO.getInstitucion());
        callableStatement.setBinaryStream(5, asistenciacursosDTO.getEvidencia().getInputstream());
        callableStatement.setInt(6, asistenciacursosDTO.getIdmodif());
        Calendar cal1 = Calendar.getInstance();
        String Fecha =
            (""
                + cal1.get(Calendar.DATE)
                + "/"
                + cal1.get(Calendar.MONTH)
                + "/"
                + cal1.get(Calendar.YEAR)
                + " "
                + cal1.get(Calendar.HOUR_OF_DAY)
                + ":"
                + cal1.get(Calendar.MINUTE)
                + ":"
                + cal1.get(Calendar.SECOND)
                + ":"
                + cal1.get(Calendar.MILLISECOND));
        callableStatement.setString(7, Fecha);
        callableStatement.setInt(8, asistenciacursosDTO.getIdlic());
        callableStatement.setInt(9, asistenciacursosDTO.getIdusuario());

        callableStatement.execute();
        Integer num = callableStatement.getInt(1);
        connection.close();
        if (num == 1) {

          return "¡Se guardo satisfactoriamente!";

        } else {
          return "";
        }

      } catch (Exception e) {
        e.printStackTrace();
      }
    } catch (Exception ex) {
      System.out.println("Error en.." + ex.getMessage());
    }

    return "";
  }
コード例 #20
0
ファイル: DbManager.java プロジェクト: IFT-SE/recommender
 /**
  * Updates an existing word and word count for a given method. This method should be only used if
  * the row already exists in the database. Existence can be verified using the
  * getWordCountFromMethodIdAndWordId(int, int) method. If the method does not exist,
  * insertWordCountForMethodIdAndWordId(int, int) should be used instead.
  *
  * @param methodId The method's database id
  * @param wordId The word's database id
  * @param wordCount The number of times the word occurs in the given method
  */
 public void updateWordCountForMethodIdAndWordId(int methodId, int wordId, int wordCount) {
   try {
     sp_updateWordCountForMethodIdAndWordId.setInt(1, methodId);
     sp_updateWordCountForMethodIdAndWordId.setInt(2, wordId);
     sp_updateWordCountForMethodIdAndWordId.setInt(3, wordCount);
     sp_updateWordCountForMethodIdAndWordId.executeUpdate();
   } catch (SQLException e) {
     eLog.logException(e);
   }
 }
コード例 #21
0
 /**
  * Function deleteReservation takes in a reservation id and seat id and deletes the reservation at
  * the values.
  *
  * @param resId
  * @param seatId
  */
 void deleteReservation(int resId, int seatId) {
   CallableStatement cs = null;
   try {
     String call = "{call delete_res(?, ?)}";
     cs = en.conn.prepareCall(call);
     cs.setInt(1, resId);
     cs.setInt(2, seatId);
     cs.executeUpdate();
     en.conn.commit();
   } catch (SQLException e) {
     System.err.println("Drop Reservation: deleteReservation - " + e.getMessage());
   }
 }
コード例 #22
0
ファイル: SDataTaxBasic.java プロジェクト: swaplicado/siie32
  @Override
  public int save(java.sql.Connection connection) {
    int nParam = 1;
    CallableStatement callableStatement = null;

    mnLastDbActionResult = SLibConstants.UNDEFINED;

    try {
      callableStatement =
          connection.prepareCall("{ CALL erp.finu_tax_bas_save(" + "?, ?, ?, ?, ?, ?, ?) }");
      callableStatement.setInt(nParam++, mnPkTaxBasicId);
      callableStatement.setString(nParam++, msTaxBasic);
      callableStatement.setBoolean(nParam++, mbIsDeleted);
      callableStatement.setInt(nParam++, mbIsRegistryNew ? mnFkUserNewId : mnFkUserEditId);
      callableStatement.registerOutParameter(nParam++, java.sql.Types.SMALLINT);
      callableStatement.registerOutParameter(nParam++, java.sql.Types.SMALLINT);
      callableStatement.registerOutParameter(nParam++, java.sql.Types.CHAR);
      callableStatement.execute();

      mnPkTaxBasicId = callableStatement.getInt(nParam - 3);
      mnDbmsErrorId = callableStatement.getInt(nParam - 2);
      msDbmsError = callableStatement.getString(nParam - 1);

      if (mnDbmsErrorId != 0) {
        throw new Exception(msDbmsError);
      } else {
        // Save aswell the taxes

        nParam = 1;

        for (int i = 0; i < mvDbmsTaxes.size(); i++) {
          mvDbmsTaxes.get(i).setPkTaxBasicId(mnPkTaxBasicId);
          if (mvDbmsTaxes.get(i).save(connection) != SLibConstants.DB_ACTION_SAVE_OK) {
            throw new Exception(SLibConstants.MSG_ERR_DB_REG_SAVE_DEP);
          }
        }

        mbIsRegistryNew = false;
        mnLastDbActionResult = SLibConstants.DB_ACTION_SAVE_OK;
      }
    } catch (java.sql.SQLException e) {
      mnLastDbActionResult = SLibConstants.DB_ACTION_SAVE_ERROR;
      SLibUtilities.printOutException(this, e);
    } catch (java.lang.Exception e) {
      mnLastDbActionResult = SLibConstants.DB_ACTION_SAVE_ERROR;
      SLibUtilities.printOutException(this, e);
    }

    return mnLastDbActionResult;
  }
コード例 #23
0
ファイル: DbManager.java プロジェクト: IFT-SE/recommender
  /**
   * Returns the number of times a word occurs for the given method's ID and word's ID. This method
   * is synchronized.
   *
   * @param methodId The database id of the method
   * @param wordId The database's id of the word
   * @return The number of times a word occurs within the method
   */
  public synchronized int getWordCountFromMethodIdAndWordId(int methodId, int wordId) {
    int rv = 0;

    try {
      sp_getWordCountsFromMethodIdAndWordId.setInt(1, methodId);
      sp_getWordCountsFromMethodIdAndWordId.setInt(2, wordId);
      rs = sp_getWordCountsFromMethodIdAndWordId.executeQuery();
      while (rs.next()) rv = rs.getInt(1);
      rs.close();
    } catch (SQLException e) {
      eLog.logException(e);
    }
    return rv;
  }
コード例 #24
0
  public void testAllInOut() throws Throwable {

    CallableStatement call = con.prepareCall("{ call test_allinout(?,?,?) }");

    call.registerOutParameter(1, Types.INTEGER);
    call.registerOutParameter(2, Types.VARCHAR);
    call.registerOutParameter(3, Types.BIGINT);
    call.setInt(1, 20);
    call.setString(2, "hi");
    call.setInt(3, 123);
    call.execute();
    call.getInt(1);
    call.getString(2);
    call.getLong(3);
  }
コード例 #25
0
ファイル: PublicacionesDAO.java プロジェクト: eightd/SICVA
  public String ActualizarEvidencia(PublicacionesDTO publicacionesDTO, int idUsuMod) {
    try {
      try {
        ConexionBD conexionBD = new ConexionBD();
        conexionBD.abrir();
        Connection connection = conexionBD.getConexion();

        String sql = "{ ? = call actualizar_evidencia_publicaciones(?,?,?,?)} ";

        CallableStatement callableStatement = connection.prepareCall(sql);
        callableStatement.registerOutParameter(1, Types.INTEGER);
        callableStatement.setInt(2, publicacionesDTO.getId());
        callableStatement.setInt(3, idUsuMod);
        Calendar cal1 = Calendar.getInstance();
        String Fecha =
            (""
                + cal1.get(Calendar.DATE)
                + "/"
                + cal1.get(Calendar.MONTH)
                + "/"
                + cal1.get(Calendar.YEAR)
                + " "
                + cal1.get(Calendar.HOUR_OF_DAY)
                + ":"
                + cal1.get(Calendar.MINUTE)
                + ":"
                + cal1.get(Calendar.SECOND)
                + ":"
                + cal1.get(Calendar.MILLISECOND));
        callableStatement.setString(4, Fecha);
        callableStatement.setBinaryStream(5, publicacionesDTO.getEvidencia().getInputstream());
        callableStatement.execute();
        Integer num = callableStatement.getInt(1);
        connection.close();
        if (num == 1) {
          return "¡Se actualizo satisfactoriamente!";
        } else {
          return "";
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
    } catch (Exception ex) {
      System.out.println("Error en ActualizarEvidencia()..." + ex.getMessage());
    }

    return "";
  }
コード例 #26
0
ファイル: DBConn.java プロジェクト: apexuser/dxdy
 @Override
 public int getLastTopicPage(int tID) {
   String proc = "{? = call dxdy_executable.get_topic_last_page(?)}";
   CallableStatement st = null;
   int res = 0;
   try {
     st = connection.prepareCall(proc);
     st.registerOutParameter(1, java.sql.Types.INTEGER);
     st.setInt(2, tID);
     st.execute();
     res = st.getInt(1);
   } catch (SQLException e) {
     System.out.println("Error while querying last page of topic ID = " + tID);
     e.printStackTrace();
   } finally {
     if (st != null) {
       try {
         st.close();
       } catch (SQLException e) {
         e.printStackTrace();
       }
     }
   }
   return res;
 }
コード例 #27
0
  public static void main(String[] args) {

    try {
      // 1.加载驱动
      Class.forName("oracle.jdbc.driver.OracleDriver");
      // 2.获取连接
      Connection connection =
          DriverManager.getConnection(
              "jdbc:oracle:thin:@127.0.0.1:1521:orcl", "SCOTT", "wcy675600920");
      // 3.创建CallableStatement
      CallableStatement cs = connection.prepareCall("{call wwss_pro3(?,?)}");
      // 4.给?赋值
      cs.setString(1, "9527");
      cs.setInt(2, 3000);
      // 5.执行
      cs.execute();
      // 6.关闭
      cs.close();
      connection.close();
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    } catch (SQLException e) {
      e.printStackTrace();
    }
  }
コード例 #28
0
  @Override
  protected Boolean vDelRow(Connection conn, ArrayList curRow) throws Exception {
    ADelDialog d = new ADelDialog(null, true);
    d.addPar("Наименование", curRow.get(1).toString());
    d.addPar("Описание", curRow.get(2).toString());

    d.setTitleIcon(
        new javax.swing.ImageIcon(
            getClass().getResource("/tradeterminal/icons/TT_icons/32X32/typdel.png")));
    d.setVisible(true);
    d.dispose();

    if (d.getReturnStatus() == ADialog.RET_OK) {
      int id = Integer.parseInt(curRow.get(0).toString());

      CallableStatement proc = conn.prepareCall("{call rb_doc_types_delete(?)}");

      proc.setInt(1, id);
      proc.execute();
      proc.close();

      return true;
    } else {
      return false;
    }
  }
コード例 #29
0
ファイル: ProcessCtl.java プロジェクト: AtrumGeost/ati_ds
  /**
   * Descripción de Método
   *
   * @param ProcedureName
   * @return
   */
  private boolean startDBProcess(String ProcedureName) {

    // execute on this thread/connection

    log.fine(ProcedureName + "(" + m_pi.getAD_PInstance_ID() + ")");

    String sql = "{call " + ProcedureName + "(?)}";

    try {
      CallableStatement cstmt = DB.prepareCall(sql); // ro??

      cstmt.setInt(1, m_pi.getAD_PInstance_ID());
      cstmt.executeUpdate();
      cstmt.close();
    } catch (Exception e) {
      log.log(Level.SEVERE, sql, e);
      m_pi.setSummary(Msg.getMsg(Env.getCtx(), "ProcessRunError") + " " + e.getLocalizedMessage());
      m_pi.setError(true);

      return false;
    }

    // log.fine(Log.l4_Data, "ProcessCtl.startProcess - done");

    return true;
  } // startDBProcess
コード例 #30
0
ファイル: DBConn.java プロジェクト: apexuser/dxdy
  @Override
  public String getLastTopicDate(int tID) {
    /*    function get_topic_last_update (p_topic_id  in dxdy_topic.id%type) return varchar2;        */
    String proc = "{? = call dxdy_executable.get_topic_last_update(?)}";
    CallableStatement st = null;
    String res = "";
    try {
      // System.out.println("Request date for topic ID = " + tID);
      st = connection.prepareCall(proc);
      st.registerOutParameter(1, Types.VARCHAR);
      st.setInt(2, tID);
      st.execute();
      res = st.getString(1);
      // System.out.println("Requested date = " + res);

    } catch (SQLException e) {
      System.out.println("Error while querying last message date of topic ID = " + tID);
      e.printStackTrace();
    } finally {
      if (st != null) {
        try {
          st.close();
        } catch (SQLException e) {
          e.printStackTrace();
        }
      }
    }
    return res;
  }