Exemplo n.º 1
0
  public JSONArray ObtenerMateriales() {
    JSONArray Materiales = new JSONArray();
    JSONObject material = new JSONObject();

    try {
      this.cn = getConnection();
      this.st = this.cn.createStatement();
      String sql;
      sql = "SELECT * FROM material";
      this.rs = this.st.executeQuery(sql);

      while (this.rs.next()) {
        Material mat = new Material(rs.getString("codigo"), rs.getString("material"));
        material = mat.getJSONObject();
        System.out.printf(material.toString());
        Materiales.add(material);
      }

      this.desconectar();
    } catch (Exception e) {
      e.printStackTrace();
    }

    return (Materiales);
  }
Exemplo n.º 2
0
 public JSONObject DatosMaterial(String Codigo) {
   JSONObject mater = new JSONObject();
   try {
     this.cn = getConnection();
     this.st = this.cn.createStatement();
     String sql = "SELECT * FROM material WHERE codigo = '" + Codigo + "';";
     this.rs = this.st.executeQuery(sql);
     this.rs.first();
     Material use = new Material(rs.getString("codigo"), rs.getString("material"));
     mater = use.getJSONObject();
     this.desconectar();
   } catch (Exception e) {
     e.printStackTrace();
   }
   return (mater);
 }