Exemple #1
0
  public boolean delete(Object[] obj) {
    String sql = "delete from cable where cableID=?";
    DbManager db = new DbManager();
    Boolean deleteResult = false;
    Cable_ConnectorDao cable_connector = new Cable_ConnectorDao();

    try {
      db.beginTrans();
      // "update device set deviceName=?,practoryName=?,deviceStyle=?,description=? where
      // deviceID=?";
      deleteResult = db.execute(sql, obj);
      // sql="delete  from deviceInter where deviceID=?";
      cable_connector.delete(obj);

      // String
      // slotSql="insert into device_slot(deviceID,slotID,num,remark) values(?,?,?,?)";
      /*
       * if(!deviceslot.delete(obj)) { System.out.println("删除错误回滚!!!");
       * deleteResult=false;
       *
       * }
       */
      db.commit();
      deleteResult = true;
    } catch (Exception e) {
      db.rollback();

      System.out.println("删除错误回滚!!!");
      deleteResult = false;
    }
    return deleteResult;
  }
Exemple #2
0
  public boolean update(Object[] obj) {
    String sql = "update cable set cableName=?,remark=? where cableID=?";

    // ('username','password','path','name','organization','370781','2012-12-12',15,'��','java','13890000000','����','����','����','�����ѵĵط�','1');"
    DbManager db = new DbManager();

    return db.execute(sql, obj);
  }
Exemple #3
0
  public boolean add(Object[] obj) {
    String sql =
        "insert into cable"
            + "(courseName,cableID,cableStyle,connectors,remark)"
            + "values"
            + "(?,?,?,?,?)";

    // ('username','password','path','name','organization','370781','2012-12-12',15,'��','java','13890000000','����','����','����','�����ѵĵط�','1');"
    DbManager db = new DbManager();

    return db.execute(sql, obj);
  }
Exemple #4
0
  public boolean add(
      Object[] obj,
      List<Cable_connectorVo> aConnectorList,
      List<Cable_connectorVo> bConnectorList) {
    boolean addResult = false;

    // String
    // sql1="insert into device_slot(deviceID,slotID,num,remark) values(?,?,?,?)";
    // String
    // sql2="insert into device_inter(deviceID,interfaceID,num,remark) values(?,?,?,?)";

    // String sql3 =
    // "insert into slot(slotName,slotID,remark)values(?,?,?)";
    // String sql4 =
    // "insert into interface(interfaceName,interfaceID,interfaceStyle,parameters,remark)
    // values(?,?,?,?,?)";
    // ('username','password','path','name','organization','370781','2012-12-12',15,'��','java','13890000000','����','����','����','�����ѵĵط�','1');"
    DbManager db = new DbManager();
    // DbManager db1 = new DbManager();
    try {
      String cableSql =
          "insert into cable"
              + "(cableName,cablestyle,connectors,cableUrl,remark,type) "
              + "values"
              + "(?,?,?,?,?,?)";

      // addResult = db1.execute(deviceSql, obj);
      db.beginTrans();

      // Object []obj={lineName,linestyle,"",boardUr,linedes,""};
      // db.execute(cableSql, obj,count);
      String conSql =
          "insert into cable_connector(cableID,inter_side,connectorType,num,interfaceStyle,remark) values(?,?,?,?,?,?)";
      int id = db.executeAndNewID(cableSql, obj);
      System.out.println("最大ID:" + id);
      for (int i = 0; i < aConnectorList.size(); i++) {
        // System.out.print("fixList->"+interArray[i]);
        // //String[] interParameters=interArray[i].split("\\$");
        // Object[]
        // interObj={obj[1],interParameters[0],Integer.parseInt(interParameters[1]),""};
        // System.out.println("->"+interParameters[0]+":"+interParameters[1]);
        System.out.println("最大ID1:" + id);
        addResult =
            db.execute(
                conSql,
                new Object[] {
                  id,
                  aConnectorList.get(i).getInter_side(),
                  aConnectorList.get(i).getConnectorType(),
                  aConnectorList.get(i).getNum(),
                  "",
                  ""
                });
      }
      // String
      // slotSql="insert into device_slot(deviceID,slotID,coords,slotName,remark)
      // values(?,?,?,?,?)";
      for (int i = 0; i < bConnectorList.size(); i++) {

        // String[] slotParameters=slotArray[i].split("\\$");
        // System.out.println("->"+slotParameters[0]+":"+slotParameters[1]);
        // Object[]
        // slotObj={obj[1],slotParameters[0],Integer.parseInt(slotParameters[1]),""};
        System.out.println("最大ID2:" + id);
        addResult =
            db.execute(
                conSql,
                new Object[] {
                  id,
                  bConnectorList.get(i).getInter_side(),
                  bConnectorList.get(i).getConnectorType(),
                  bConnectorList.get(i).getNum(),
                  "",
                  ""
                });
      }
      db.commit();
      // addResult=true;
    } catch (Exception e) {
      addResult = false;
      db.rollback();

      System.out.println("添加失败回滚!!!");
    }
    return addResult;
  }