Пример #1
0
  public void actualizar(partners pa) throws Exception {
    try {
      this.Conectar();
      System.out.println("Aqui vamos");
      String query =
          "update partner set name=?, lastname=?, street=?, noExt=?, noInt=?, colony=?, zip=?, locality=?, phone=?, mobile=?, email=?, customer=? ,supplier=?, image=?,city_id=?,state_id=?,country_id=?,active=? where id=?";
      PreparedStatement st = this.getCon().prepareStatement(query);
      st.setString(1, pa.getName());
      st.setString(2, pa.getLastName());
      st.setString(3, pa.getStreet());
      st.setString(4, pa.getNoExt());
      st.setString(5, pa.getNoInt());
      st.setString(6, pa.getColony());
      st.setString(7, pa.getZip());
      st.setString(8, pa.getLocality());
      st.setString(9, pa.getPhone());
      st.setString(10, pa.getMobile());
      st.setString(11, pa.getEmail());
      st.setBoolean(12, pa.getCustomer());
      st.setBoolean(13, pa.isSupplier());
      st.setBytes(14, pa.getImage());
      st.setInt(15, pa.getCity_id());
      st.setInt(16, pa.getState_id());
      st.setInt(17, pa.getCity_id());
      st.setInt(18, pa.getActive());
      st.setInt(19, pa.getIdPartner());
      st.executeUpdate();
    } catch (Exception e) {
      throw e;
    } finally {

      this.Cerrar();
    }
  }
Пример #2
0
 public partners LeerID(partners pa) throws Exception {
   partners part = null;
   ResultSet rs;
   try {
     this.Conectar();
     PreparedStatement st =
         this.getCon().prepareStatement("" + "select * from partner where id= ? ");
     st.setInt(1, pa.getIdPartner());
     rs = st.executeQuery();
     while (rs.next()) {
       part = new partners();
       part.setIdPartner(rs.getInt("id"));
       part.setName(rs.getString("name"));
       part.setLastName(rs.getString("lastname"));
       part.setStreet(rs.getString("street"));
       part.setNoExt(rs.getString("noExt"));
       part.setNoInt(rs.getString("noInt"));
       part.setColony(rs.getString("Colony"));
       part.setZip(rs.getString("Zip"));
       part.setLocality(rs.getString("Locality"));
       part.setPhone(rs.getString("Phone"));
       part.setMobile(rs.getString("Mobile"));
       part.setCustomer(rs.getBoolean("Customer"));
       part.setSupplier(rs.getBoolean("Supplier"));
       part.setImage(rs.getBytes("image"));
       part.setCity_id(rs.getInt("City_id"));
       part.setState_id(rs.getInt("State_id"));
       part.setCountry_id(rs.getInt("Country_id"));
     }
   } catch (Exception e) {
     throw e;
   } finally {
     this.Cerrar();
   }
   return part;
 }