Beispiel #1
1
 public ArrayList<ListaAlquiler> get_alquiler_byclientefecha(String condicion) {
   Connection cnn = null;
   CallableStatement cstmt = null;
   ArrayList<ListaAlquiler> listAlquiler = new ArrayList<ListaAlquiler>();
   try {
     cnn = BD.getConnection();
     String sql = "select * from  get_alquiler_byclientefecha where " + condicion;
     cstmt = cnn.prepareCall(sql);
     ResultSet rs = cstmt.executeQuery();
     while (rs.next()) {
       ListaAlquiler a = new ListaAlquiler();
       a.setIdCliente(rs.getInt("int_id"));
       a.setVar_nombre_cliente(rs.getString("var_nombre_cliente"));
       a.setVar_apepaterno(rs.getString("var_apepaterno"));
       a.setVar_apematerno(rs.getString("var_apematerno"));
       a.setVar_nombre_material(rs.getString("var_nombre_material"));
       a.setDat_fechinicio(rs.getTimestamp("dat_fechinicio"));
       a.setDat_fechfin(rs.getTimestamp("dat_fechfin"));
       a.setInt_cantidad(rs.getInt("int_cantidad"));
       a.setDec_monto(rs.getDouble("dec_monto"));
       a.setDat_fechaRegistro(rs.getTimestamp("dat_fechaRegistro"));
       a.setVar_numero(rs.getString("var_numero"));
       listAlquiler.add(a);
     }
     cstmt.close();
     cnn.close();
   } catch (SQLException a) {
     System.out.println("" + a);
   }
   return listAlquiler;
 }
 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;
 }
  public static Servicios ObtenerServicios(int IdServicio) throws Exception {

    Servicios miServicio = null;
    CallableStatement ObjProcedimiento;
    Connection conector = estado();

    try {

      ObjProcedimiento = conector.prepareCall("{call ObtenerServicios(?)}");
      ObjProcedimiento.setInt(1, IdServicio);

      ResultSet respuesta = ObjProcedimiento.executeQuery();
      miServicio = new Servicios();
      while (respuesta.next()) {
        miServicio.setIdServicio(respuesta.getInt(1));
        miServicio.setNombre(respuesta.getString(2));
      }

    } catch (Exception pp) {
      JOptionPane.showMessageDialog(
          null,
          "Error en Catalogo: ObtenerServicios " + pp.getMessage(),
          "ATENCION",
          JOptionPane.WARNING_MESSAGE);
    } finally {
      conector.close();
    }

    return miServicio;
  }
  public User getUser(String username) {
    con = new DBConnection();
    User objUser = null;
    try {

      cstmt = con.connection.prepareCall("{call getUser(?)}");
      cstmt.setString(1, username);
      ResultSet rsUser = cstmt.executeQuery();

      if (rsUser.next()) {
        objUser = new User();
        objUser.setUserName(rsUser.getString("UserName"));
        objUser.setPassword(rsUser.getString("Password"));
        UserRole objUserRole = new UserRole();
        objUserRole.setRole(rsUser.getString("Role"));
        objUser.setUsertype(objUserRole);
      }

    } catch (Exception e) {
      e.getMessage();
    } finally {
      con.closeConnection();
    }
    return objUser;
  }
  public static ArrayList<Servicios> ListadoServicios() throws Exception {

    ArrayList<Servicios> lista = new ArrayList<Servicios>();
    CallableStatement ObjProcedimiento;
    Connection conector = estado();

    try {

      ObjProcedimiento = conector.prepareCall("{call ListarServicios()}");
      ResultSet respuesta = ObjProcedimiento.executeQuery();
      if (respuesta.next()) {
        do {
          Servicios miServicio = new Servicios(respuesta.getInt(1), respuesta.getString(2));
          lista.add(miServicio);

        } while (respuesta.next());
      }

    } catch (Exception pp) {
      JOptionPane.showMessageDialog(
          null,
          "Error en Catalogo: ListadoServicios " + pp.getMessage(),
          "ATENCION",
          JOptionPane.WARNING_MESSAGE);
    } finally {
      conector.close();
    }

    return lista;
  }
Beispiel #6
0
  public static List<Pago> buscarPagos() {
    ConnectionPool pool = ConnectionPool.getInstance();
    Connection connection = pool.getConnection();
    CallableStatement cs = null;
    ResultSet rs = null;
    try {
      List<Pago> pagos = new ArrayList();
      cs = connection.prepareCall("{ call listaPago() }");
      rs = cs.executeQuery();
      while (rs.next()) {
        Pago pag = new Pago(rs.getInt("idMetodoPago"), rs.getString("nombreMetodoPago"));

        pagos.add(pag);
      }
      return pagos;
    } catch (Exception ex) {
      ex.printStackTrace();
      return null;

    } finally {
      DBUtil.closeResultSet(rs);
      DBUtil.closeStatement(cs);
      pool.freeConnection(connection);
    }
  }
Beispiel #7
0
  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);
    }
  }
Beispiel #8
0
 public Guia obtener(int id) throws Exception {
   Guia objeto = new Guia();
   try {
     cnn = Conexion.getConexion();
     CallableStatement cs = null;
     cs = cnn.prepareCall("call uspGetGuia(?)");
     cs.setInt(1, id);
     rs = cs.executeQuery();
     while (rs.next()) {
       objeto.setIdGuia(rs.getInt("Idguia"));
       objeto.setPeriodo(rs.getString("Periodo"));
       objeto.setNumero(rs.getString("Numero"));
       objeto.setFecha(rs.getString("Fecha"));
       objeto.setTipoCambio(rs.getDouble("Tipocambio"));
       objeto.setSerie(rs.getString("Serie"));
       objeto.setNumeroDocumento(rs.getString("Numerodocumento"));
       objeto.setIdTipoMovimiento(rs.getInt("Idtipomovimiento"));
       objeto.setReferencia(rs.getString("Referencia"));
       objeto.setIdOrdenProduccion(rs.getInt("Idordenproduccion"));
       objeto.setIdClienteProveedor(rs.getInt("Idclienteproveedor"));
       objeto.setIdAlmacen(rs.getInt("Idalmacen"));
       objeto.setObservaciones(rs.getString("Observaciones"));
       objeto.setDOrdenProduccion(rs.getString("DOrdenProduccion"));
       objeto.setDClienteProveedor(rs.getString("DClienteProveedor"));
     }
     cnn.close();
     cs.close();
   } catch (SQLException ex) {
     throw ex;
   }
   return objeto;
 }
Beispiel #9
0
  public static List<Departamento> buscarDepartamentos() {
    ConnectionPool pool = ConnectionPool.getInstance();
    Connection connection = pool.getConnection();
    CallableStatement cs = null;
    ResultSet rs = null;
    try {
      List<Departamento> departamentos = new ArrayList();
      cs = connection.prepareCall("{ call listaDepartamento() }");
      rs = cs.executeQuery();
      while (rs.next()) {
        Departamento dpo =
            new Departamento(rs.getInt("idDepartamento"), rs.getString("nombreDepartamento"));

        departamentos.add(dpo);
      }
      return departamentos;
    } catch (Exception ex) {
      ex.printStackTrace();
      return null;

    } finally {
      DBUtil.closeResultSet(rs);
      DBUtil.closeStatement(cs);
      pool.freeConnection(connection);
    }
  }
  // ---------------combo para seleccionar el tipo d epersona
  public static List<TipoPersona> getCargarComboTipoPersona() {
    List<TipoPersona> arreglo = null;
    TipoPersona obj = null;
    Connection conexion = null;
    ResultSet rs = null;
    try {
      conexion = ControladorBD.darConexionBD();
      CallableStatement st = conexion.prepareCall("{call sp_combo_tipo_persona()}");
      rs = st.executeQuery();
      if (rs.next()) {
        arreglo = new ArrayList<TipoPersona>();
        do {
          obj = new TipoPersona();

          obj.setId_tipo_persona(rs.getInt("id_tipo_persona"));
          obj.setNombre(rs.getString("nombre"));

          arreglo.add(obj);
        } while (rs.next());
      }
      rs.close();
      st.close();
      conexion.close();
    } catch (Exception error) {
      System.out.println("Error en el metodo por: " + error.getMessage());
      error.printStackTrace();
    }

    return arreglo;
  }
  public FaqCategories selectById(int id) throws SQLException {
    try {
      connection = ConnectionFactory.getInstance().getConnection();
      cs = connection.prepareCall("{call faq_categories_FindByPK(?)}");

      cs.setInt(1, id);

      resultSet = cs.executeQuery();
      FaqCategories faqc = null;
      while (resultSet.next()) {
        faqc =
            new FaqCategories(
                resultSet.getInt("idFAQ_Categories"),
                resultSet.getInt("idLanguage"),
                resultSet.getString("category_name"),
                resultSet.getString("category_description"));
      }
      return faqc;
    } finally {
      if (resultSet != null) {
        resultSet.close();
      }
      if (cs != null) {
        cs.close();
      }
      if (connection != null) {
        connection.close();
      }
    }
  }
Beispiel #12
0
 public String getStatuses() {
   ResultSet rs = null;
   try (CallableStatement cs = conn.prepareCall("{call ti_getStatuses}")) {
     rs = cs.executeQuery();
     if (rs != null) {
       ArrayList<Status> statuses = new ArrayList<>();
       while (rs.next()) {
         // (int status_id, String displayName, boolean isSystem, boolean isNotify, boolean
         // isClosed, String notifyMsg)
         statuses.add(
             new Status(
                 rs.getInt("status_id"),
                 rs.getString("display_name"),
                 rs.getBoolean("isSystem"),
                 rs.getBoolean("isNotify"),
                 rs.getBoolean("isClosed"),
                 rs.getString("notify_msg")));
       }
       StatusList statusList = new StatusList(statuses);
       return generateGson(statusList);
     }
   } catch (SQLException e) {
     e.printStackTrace();
   }
   return "";
 }
Beispiel #13
0
  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;
  }
  public List<TypeBean> TypeList() {
    List<TypeBean> list = new ArrayList<TypeBean>();
    Connection conn = null;

    CallableStatement stmt = null;
    ResultSet rs = null;
    try {
      conn = DbConnection.getConnection();
      stmt = conn.prepareCall("{call product_type()}");
      // String select = "select type_id,p_type FROM product_type";
      //			stmt.setString(1, "type_id");
      //			stmt.setString(2, "p_type");
      // .executeQuery("CREATE PROCEDURE shopping_expo.product_type(IN type_id INT , IN p_type
      // nvarchar(30)) BEGIN	select type_id,p_type FROM product_type;END;");
      System.out.println("Type Callable Executed");
      rs = stmt.executeQuery();
      while (rs.next()) {
        lb = new TypeBean();
        lb.setpType_Id(rs.getString("TYPE_ID"));
        lb.setpType(rs.getString("P_TYPE"));
        list.add(lb);
      }
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    return list;
  }
  public List<TypeBean> list() {
    List<TypeBean> list = new ArrayList<TypeBean>();
    Connection conn = null;

    CallableStatement stmt = null;
    ResultSet rs = null;
    try {
      conn = DbConnection.getConnection();
      stmt = conn.prepareCall("{CALL  getAllTypeProcedure()}");

      //	String select = "select * from product_type";

      rs = stmt.executeQuery();

      while (rs.next()) {
        lb = new TypeBean();
        lb.setpType_Id(rs.getString("TYPE_ID"));
        lb.setpType(rs.getString("P_TYPE"));
        list.add(lb);
      }
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      System.out.println("Exception :" + e.getMessage() + e.getErrorCode());
      e.printStackTrace();
    }

    return list;
  }
  public ArrayList getAllItems() {
    con = new DBConnection();
    ArrayList list = new ArrayList();
    try {

      cstmt = con.connection.prepareCall("{call getAllItemsForAdmin ()}");
      ResultSet rs = cstmt.executeQuery();
      while (rs.next()) {
        Map objMap = new HashMap();
        objMap.put("ItemID", rs.getInt("ItemID"));
        objMap.put("ItemName", rs.getString("ItemName"));
        objMap.put("TypeID", rs.getInt("TypeID"));
        objMap.put("TypeName", rs.getString("TypeName"));
        objMap.put("UserName", rs.getString("UserName"));

        list.add(objMap);
      }
      rs.close();
    } catch (Exception ex) {
      ex.getMessage();
    } finally {
      con.closeConnection();
    }
    return list;
  }
  public List<Area> getAllArea() {
    List<Area> areaList = new ArrayList<Area>();
    con = new DBConnection();
    try {

      cstmt = con.connection.prepareCall("{call getAllArea()}");
      ResultSet rs = cstmt.executeQuery();

      while (rs.next()) {

        Area objArea = new Area();
        objArea.setAreaID(rs.getInt("AreaID"));
        objArea.setAreaName(rs.getString("AreaName"));
        City c = new City();
        c.setCityName(rs.getString("CityName"));
        objArea.setCity(c);

        areaList.add(objArea);
      }
      rs.close();
    } catch (Exception ex) {
      ex.getMessage();
    } finally {

      con.closeConnection();
    }
    return areaList;
  }
  public List<ItemType> getAllItemType() {
    List<ItemType> typeList = new ArrayList<ItemType>();
    con = new DBConnection();
    try {

      cstmt = con.connection.prepareCall("{call  getAllItemType()}");
      ResultSet rs = cstmt.executeQuery();

      while (rs.next()) {

        ItemType objItemType = new ItemType();
        objItemType.setTypeName(rs.getString("TypeName"));
        objItemType.setTypeID(rs.getInt("TypeID"));

        typeList.add(objItemType);
      }
      rs.close();
    } catch (Exception ex) {
      ex.getMessage();
    } finally {

      con.closeConnection();
    }
    return typeList;
  }
  public ArrayList<FaqCategories> select() throws SQLException {
    try {
      connection = ConnectionFactory.getInstance().getConnection();
      cs = connection.prepareCall("{Call faq_categories_FindAll}");
      resultSet = cs.executeQuery();

      ArrayList<FaqCategories> list = new ArrayList<FaqCategories>();
      while (resultSet.next()) {
        FaqCategories faqc =
            new FaqCategories(
                resultSet.getInt("idFAQ_Categories"),
                resultSet.getInt("idLanguage"),
                resultSet.getString("categoy_name"),
                resultSet.getString("category_description"));
        list.add(faqc);
      }
      return list;
    } finally {
      if (resultSet != null) {
        resultSet.close();
      }
      if (cs != null) {
        cs.close();
      }
      if (connection != null) {
        connection.close();
      }
    }
  }
  @Override
  public List<MaterialBean> buscarMateriales(int codTipoMaterial, String descripcion)
      throws Exception {

    Connection cn = MySqlDbConn.obtenerConexion();
    CallableStatement st = cn.prepareCall("{ call pr_buscarMateriales(?, ?) }");
    st.setInt(1, codTipoMaterial);
    st.setString(2, descripcion);

    ResultSet rs = st.executeQuery();

    ArrayList<MaterialBean> arr = new ArrayList<MaterialBean>();

    while (rs.next()) {
      MaterialBean material = new MaterialBean();
      material.setStrCodMaterial(rs.getString("cod_mat"));
      material.setIntCodTipoMaterial(rs.getInt("cod_tip_mat"));
      material.setStrTipoMaterial(rs.getString("tip_mat"));
      material.setStrDescripMaterial(rs.getString("desc_mat"));
      material.setStrUnidadMedida(rs.getString("und_med_mat"));
      material.setBdPrecioUnitario(rs.getBigDecimal("prec_uni_mat"));
      arr.add(material);
    }
    rs.close();
    cn.close();
    return arr;
  }
  @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";
    }
  }
  private void cargar() {

    DefaultTableModel tabla = new DefaultTableModel();
    try {
      tabla.addColumn("CODIGO");
      tabla.addColumn("NOMBRES");
      tabla.addColumn("APELLIDOS");
      tabla.addColumn("SEXO");
      tabla.addColumn("DNI");
      tabla.addColumn("TELEFONO");
      tabla.addColumn("RUC");
      tabla.addColumn("E_MAIL");
      tabla.addColumn("DIRECCION");
      cts = cn.prepareCall("{call mostrarclientes}");
      r = cts.executeQuery();
      while (r.next()) {
        Object dato[] = new Object[9];
        for (int i = 0; i < 9; i++) {
          dato[i] = r.getString(i + 1);
        }
        tabla.addRow(dato);
      }
      this.jTable1.setModel(tabla);
      jLabel2.setText("" + jTable1.getRowCount());
    } catch (Exception e) {
    }
  }
  @Override
  public ResultSet ExecuteSproc(String sprocName, String[] parameters, int[] returnColumnTypes)
      throws SQLException {
    if (_conn.isClosed()) {
      throw new SQLException("Connection was already closed");
    }

    try {

      String paramsList = "";

      int listSize = parameters.length;
      for (int i = 0; i < listSize; i++) {
        paramsList += parameters[i];
        if (i != listSize - 1) {
          paramsList += ", ";
        }
      }

      CallableStatement statement =
          _conn.prepareCall("{call " + sprocName + "(" + paramsList + ")}");

      for (int i = 0; i < returnColumnTypes.length; i++) {
        statement.registerOutParameter(i + 1, returnColumnTypes[i]);
      }

      return statement.executeQuery();
    } catch (SQLException ex) {
      throw ex;
    }
  }
Beispiel #24
0
 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;
 }
Beispiel #25
0
  public static List<Sucursal> buscarSucursales() {
    ConnectionPool pool = ConnectionPool.getInstance();
    Connection connection = pool.getConnection();
    CallableStatement cs = null;
    ResultSet rs = null;
    try {
      List<Sucursal> sucursales = new ArrayList();
      cs = connection.prepareCall("{ call listaSucursal() }");
      rs = cs.executeQuery();
      while (rs.next()) {
        Sucursal suc = new Sucursal(rs.getInt("idSucursal"), rs.getString("nombreSucursal"));

        sucursales.add(suc);
      }
      return sucursales;
    } catch (Exception ex) {
      ex.printStackTrace();
      return null;

    } finally {
      DBUtil.closeResultSet(rs);
      DBUtil.closeStatement(cs);
      pool.freeConnection(connection);
    }
  }
  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
Beispiel #27
0
  public static List<Usuario> buscarUsuarios() {
    ConnectionPool pool = ConnectionPool.getInstance();
    Connection connection = pool.getConnection();
    CallableStatement cs = null;
    ResultSet rs = null;
    try {
      List<Usuario> usuas = new ArrayList();
      cs = connection.prepareCall("{ call cajeroReporte() }");
      rs = cs.executeQuery();
      while (rs.next()) {
        Usuario usa =
            new Usuario(
                rs.getString("nombreUsuario"),
                rs.getString("apellidoPaterno"),
                rs.getInt("idUsuario"));

        usuas.add(usa);
      }
      return usuas;
    } catch (Exception ex) {
      ex.printStackTrace();
      return null;

    } finally {
      DBUtil.closeResultSet(rs);
      DBUtil.closeStatement(cs);
      pool.freeConnection(connection);
    }
  }
  public static void reload() throws SQLException {
    String query = "{call GetGift()}";
    try (Connection conn = DBPoolConnection.getConnection();
        CallableStatement cs = conn.prepareCall(query);
        ResultSet rs = cs.executeQuery()) {
      if (rs != null) {
        while (rs.next()) {
          int id = rs.getInt("GiftGameID");
          String name = rs.getString("name");
          String category = rs.getString("typeName");
          String icon = rs.getString("icon");
          String bigIcon = rs.getString("bigIcon");
          long price = rs.getLong("price");
          int giftTypeID = rs.getInt("giftTypeID");
          String activeChat = rs.getString("activeChat");
          String passiveChat = rs.getString("passiveChat");
          GiftGameEntity ent =
              new GiftGameEntity(
                  id, name, category, giftTypeID, icon, bigIcon, price, activeChat, passiveChat);

          giftGames.put(ent.id, ent);
          if (!giftType.containsKey(giftTypeID)) {
            giftType.put(giftTypeID, category);
          }
        }
      }
    }
  }
  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 ArrayList getVendorMenuDinner(String vendor) {
   con = new DBConnection();
   ArrayList list = new ArrayList();
   try {
     cstmt = con.connection.prepareCall("{call getVendorMenuDinner (?)}");
     cstmt.setString(1, vendor);
     ResultSet rs = cstmt.executeQuery();
     while (rs.next()) {
       Map objMap = new HashMap();
       objMap.put("MenuID", rs.getInt("MenuID"));
       objMap.put("UploadDateTime", rs.getDate("UploadDateTime"));
       objMap.put("TiffinDescription", rs.getString("TiffinDescription"));
       objMap.put("ItemID", rs.getInt("ItemID"));
       objMap.put("ItemName", rs.getString("ItemName"));
       objMap.put("TypeName", rs.getString("TypeName"));
       objMap.put("Cost", rs.getInt("Cost"));
       objMap.put("Quantity", rs.getInt("Quantity"));
       list.add(objMap);
     }
     rs.close();
   } catch (Exception ex) {
     ex.getMessage();
   } finally {
     con.closeConnection();
   }
   return list;
 }