Exemple #1
0
  /*
   * 功能:更新某一栏目参数:编写:石彦杰 2011-9-28修改:
   */
  public boolean updateCurrentLm(int id, String updateValue, int lmLevel) {
    boolean returnVlue = false;
    try {
      conn = baseDAO.getConn();
      if (lmLevel == 0)
        conn.createStatement()
            .executeUpdate(
                "update lm set lm='" + updateValue.trim() + "' where id=" + String.valueOf(id));
      if (lmLevel == 1)
        conn.createStatement()
            .executeUpdate(
                "update lm set lm2='" + updateValue.trim() + "' where id=" + String.valueOf(id));
      if (lmLevel == 2)
        conn.createStatement()
            .executeUpdate(
                "update lm set lm3='" + updateValue.trim() + "' where id=" + String.valueOf(id));

      returnVlue = true;

    } catch (Exception ee) {
      ee.printStackTrace();
      returnVlue = false;
    }
    baseDAO.closeAll(conn);
    return returnVlue;
  }
Exemple #2
0
  /*parames:lmUnion1,lmUnion2:将编号为lmUnion1栏目合并到编号为lmUnion2的栏目中
   * 功能:成功与否,
   * 编写:石彦杰 2011-9-28
   * 修改:
   */
  public boolean lmUnion(int lmUnion1, int lmUnion2) {
    boolean returnVlue = false;
    try {
      conn = baseDAO.getConn();
      // 先合并,后删除
      conn.createStatement()
          .executeUpdate(
              "update lm set lmid='"
                  + String.valueOf(lmUnion2).trim()
                  + "' where lmid='"
                  + String.valueOf(lmUnion1).trim()
                  + "'");
      // 删除lmUnion1
      conn.createStatement()
          .executeUpdate("delete from lm  where id=" + String.valueOf(lmUnion1).trim());

      returnVlue = true;
    } catch (Exception ee) {
      ee.printStackTrace();
      returnVlue = false;
    }
    baseDAO.closeAll(conn);

    return returnVlue;
  }
Exemple #3
0
  /*  检索栏目
   * 功能:返回某一父栏目所有的子栏目名称
   * 参数:id,lmLevel:栏目号和栏目级别
   */
  public Map<Integer, String> selectAllSubLmNameAndKey(int id, int lmLevel) {
    Map<Integer, String> returnVlue = new HashMap<Integer, String>();
    try {
      conn = baseDAO.getConn();
      //
      if (lmLevel == 1) // 检索二级栏目
      rs =
            conn.createStatement()
                .executeQuery(
                    "select id,lm2 from lm where lm2<>'' and lmid='" + String.valueOf(id) + "'");
      if (lmLevel == 2) // 检索三级栏目
      rs =
            conn.createStatement()
                .executeQuery(
                    "select id,lm3 from lm where lm3<>'' and lmid='" + String.valueOf(id) + "'");

      while (rs.next()) {
        returnVlue.put(rs.getInt("id"), rs.getString("lm2"));
      }
    } catch (Exception ee) {
      ee.printStackTrace();
    }
    baseDAO.closeAll(conn);
    return returnVlue;
  }
Exemple #4
0
  /*
   * 功能:返回栏目,
   * 编写:石彦杰 2011-9-28
   * 修改:
   */
  public Lm selectLmObject(int lmid) {
    Lm lm = new Lm();
    try {
      conn = baseDAO.getConn();

      rs = conn.createStatement().executeQuery("select * from lm");
      while (rs.next()) {
        int id = rs.getInt("id");
        if (id == lmid) {
          lm.setId(lmid);
          lm.setLm(rs.getString("lm"));
          lm.setLm2(rs.getString("lm2"));
          lm.setLm3(rs.getString("lm3"));
          lm.setMb(rs.getString("mb"));
          lm.setLmid(rs.getString("lmid"));
          break;
        }
      }
    } catch (Exception ee) {
      ee.printStackTrace();
    }
    baseDAO.closeAll(conn);

    return lm;
  }
Exemple #5
0
 /**
  * 带一个参数的删除动作
  *
  * @param sql
  * @param paramValue
  * @param paramType
  * @throws E5Exception
  */
 public static void delete(String sql, Object paramValue, Type paramType) throws E5Exception {
   try {
     BaseDAO dao = new BaseDAO();
     dao.delete(sql, paramValue, paramType);
   } catch (HibernateException e) {
     throw new E5Exception(e);
   }
 }
Exemple #6
0
 /**
  * 不带参数的删除动作,外传入Session
  *
  * @param sql
  * @param paramValue
  * @param paramType
  * @throws E5Exception
  */
 public static void delete(String sql, Session s) throws E5Exception {
   try {
     BaseDAO dao = new BaseDAO();
     dao.delete(sql, s);
   } catch (HibernateException e) {
     throw new E5Exception(e);
   }
 }
Exemple #7
0
 /**
  * 带多个参数的查找动作
  *
  * @param query HQL查找语句
  * @param paramValue 参数的值数组
  * @param s
  * @return
  * @throws E5Exception
  */
 public static List find(String sql, Object[] paramValue, Session s) throws E5Exception {
   try {
     BaseDAO dao = new BaseDAO();
     return dao.find(sql, paramValue, s);
   } catch (HibernateException e) {
     throw new E5Exception(e);
   }
 }
Exemple #8
0
 /**
  * 不带参数的查找动作
  *
  * @param sql
  * @param paramValue
  * @param paramType
  * @return
  * @throws E5Exception
  */
 public static List find(String sql) throws E5Exception {
   try {
     BaseDAO dao = new BaseDAO();
     return dao.find(sql);
   } catch (HibernateException e) {
     throw new E5Exception(e);
   }
 }
Exemple #9
0
 /**
  * 带多个参数的查找动作
  *
  * <p>从Hibernate2.0升级到Hibernate3.0时本方法被迫改动
  *
  * @param query HQL查找语句
  * @param paramName HQL语句中的参数名数组
  * @param paramValue 参数的值数组
  * @param paramType 参数的类型数组
  * @return
  * @throws E5Exception
  */
 public static List find(String sql, String[] paramName, Object[] paramValue, Type[] paramType)
     throws E5Exception {
   try {
     BaseDAO dao = new BaseDAO();
     return dao.find(sql, paramName, paramValue, paramType);
   } catch (HibernateException e) {
     throw new E5Exception(e);
   }
 }
Exemple #10
0
 /**
  * 带多个参数的删除动作,传入Session
  *
  * <p>从Hibernate2.0升级到Hibernate3.0时本方法被迫改动 <br>
  * 因为3.0后去掉了带参数(Object[], Type[])的方法,无法直接调用 <br>
  * 不能使用Query.getNamedParameters来获取参数名称, 因为该方法返回的数组是从Map中得到的,顺序不固定
  *
  * @param query HQL删除语句
  * @param paramName HQL语句中的参数名数组
  * @param paramValue 参数的值数组
  * @param paramType 参数的类型数组
  * @param s
  * @throws E5Exception
  */
 public static void delete(
     String sql, String[] paramName, Object[] paramValue, Type[] paramType, Session s)
     throws E5Exception {
   try {
     BaseDAO dao = new BaseDAO();
     dao.delete(sql, paramName, paramValue, paramType, s);
   } catch (HibernateException e) {
     throw new E5Exception(e);
   }
 }
Exemple #11
0
 /*
  * 功能:增加栏目 参数:lmName--增加的栏目名称,pLmName---栏目的父栏目名称,如果为空,则是根栏目
  * 编写:石彦杰 2011-9-28
  * 修改:
  */
 public boolean addLmByRootName(String lmName, String pLmName) {
   boolean returnVlue = false;
   if (pLmName.trim().length() == 0) // 增加根栏目
   {
     try {
       conn = baseDAO.getConn();
       rs =
           conn.createStatement()
               .executeQuery("select * from lm  where lm='" + lmName.trim() + "'");
       if (rs.next()) // 库中已存在该栏目
       {
         returnVlue = false;
       } else {
         conn.createStatement()
             .executeUpdate("insert into lm(lm) values('" + lmName.trim() + "')");
         returnVlue = true;
       }
     } catch (Exception ee) {
       returnVlue = false;
       ee.printStackTrace();
     }
     baseDAO.closeAll(conn);
   } else {
     try {
       conn = baseDAO.getConn();
       // 获得父栏目的id
       int pid = selectLmId(pLmName, false);
       if (pid != 0) {
         rs =
             conn.createStatement()
                 .executeQuery("select * from lm  where lm2='" + lmName.trim() + "'");
         if (rs.next()) // 库中已存在该子栏目
         {
           returnVlue = false;
         } else {
           conn.createStatement()
               .executeUpdate(
                   "insert into lm(lm2,lmid) values('"
                       + lmName.trim()
                       + "','"
                       + String.valueOf(pid)
                       + "')");
           returnVlue = true;
         }
       } else
         // 父目录不存在,没有得到id
         returnVlue = false;
     } catch (Exception ee) {
       returnVlue = false;
       ee.printStackTrace();
     }
     baseDAO.closeAll(conn);
   }
   return returnVlue;
 }
Exemple #12
0
 /*
  * 功能:返回所有子栏目名称参数:编写:石彦杰 2011-9-28修改:
  */
 public List<String> selectAllSubLmName() {
   List<String> returnVlue = new ArrayList<String>();
   try {
     conn = baseDAO.getConn();
     rs = conn.createStatement().executeQuery("select lm2 from lm where lm2<>''");
     while (rs.next()) returnVlue.add(rs.getString("lm2"));
   } catch (Exception ee) {
     ee.printStackTrace();
   }
   baseDAO.closeAll(conn);
   return returnVlue;
 }
Exemple #13
0
  /*
   * 功能:返回栏目id
   * 参数:lmName--栏目名称,optionType:true\false:connect(close)\don‘t connect(close) DB
   * 编写:石彦杰 2011-9-28
   * 修改:
   */
  public int getLmId(String lmName, int lmLevel, boolean optionType) {
    int returnVlue = 0;
    try {
      if (optionType) conn = baseDAO.getConn();
      rs = conn.createStatement().executeQuery("select id,lm,lm2,lm3 from lm");
      boolean have = false;
      // 搜索一级栏目找
      if (lmLevel == 1) // 一级栏目
      {
        while (rs.next()) {
          returnVlue = rs.getInt("id");
          String lm = rs.getString("lm");
          if (lm == null) continue;
          if (lm.equals(lmName)) {
            have = true;
            break;
          }
        }
      }
      //
      if (lmLevel == 2) // 二级栏目
      {
        while (rs.next() && have == false) {
          returnVlue = rs.getInt("id");
          String lm2 = rs.getString("lm2");
          if (lm2 == null) continue;
          if (lm2.equals(lmName)) {
            have = true;
            break;
          }
        }
      }
      //
      if (lmLevel == 3) // 三级栏目
      {
        while (rs.next() && have == false) {
          returnVlue = rs.getInt("id");
          String lm3 = rs.getString("lm3");
          if (lm3 == null) continue;
          if (lm3.equals(lmName)) {
            have = true;
            break;
          }
        }
      }
    } catch (Exception ee) {
      ee.printStackTrace();
    }
    if (optionType) baseDAO.closeAll(conn);

    return returnVlue;
  }
Exemple #14
0
 /*
  * 功能:返回所有子栏目名称及其id参数:编写:石彦杰 2011-9-28修改:
  */
 public Map<Integer, String> selectAllSubLmNameAndKey() {
   Map<Integer, String> returnVlue = new HashMap<Integer, String>();
   try {
     conn = baseDAO.getConn();
     //
     rs = conn.createStatement().executeQuery("select id,lm2 from lm where lm2<>''");
     while (rs.next()) {
       returnVlue.put(rs.getInt("id"), rs.getString("lm2"));
     }
   } catch (Exception ee) {
     ee.printStackTrace();
   }
   baseDAO.closeAll(conn);
   return returnVlue;
 }
 @Override
 public int countTotalSearch() {
   Connection connection = null;
   PreparedStatement stm = null;
   ResultSet rs = null;
   try {
     connection = BaseDAO.getConnect();
     stm = connection.prepareStatement("SELECT COUNT(resultID) as \"Total\" FROM result");
     rs = stm.executeQuery();
     if (rs.next()) {
       return rs.getInt("Total");
     }
   } catch (Exception e) {
     e.printStackTrace();
   } finally {
     if (stm != null) {
       try {
         stm.close();
       } catch (SQLException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
       }
     }
     if (connection != null) {
       try {
         connection.close();
       } catch (SQLException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
       }
     }
   }
   return 0;
 }
Exemple #16
0
 /*     */ public static String getSequence(String tableName, int companyID) /*     */ {
   /* 218 */ String oRet = null;
   /* 219 */ Connection conn = null;
   /*     */ try {
     /* 221 */ conn = ServiceLocator.getConnection(SQLUtils.class);
     /* 222 */ BaseDAO dao = new BaseDAO();
     /* 223 */ dao.setConnection(conn);
     /* 224 */ oRet = dao.getSequence(tableName, companyID);
     /*     */ } catch (Exception e) {
     /* 226 */ e.printStackTrace();
     /* 227 */ return null;
     /*     */ } finally {
     /* 229 */ ServiceLocator.closeConnection(SQLUtils.class, conn);
     /*     */ }
   /* 231 */ return oRet;
   /*     */ }
 @Override
 public Boolean delete(int id) {
   Connection connection = null;
   PreparedStatement stm = null;
   try {
     connection = BaseDAO.getConnect();
     stm =
         connection.prepareStatement(
             "UPDATE trafficdb.result SET isActive = false WHERE resultID=?");
     stm.setInt(1, id);
     return stm.executeUpdate() > 0;
   } catch (Exception e) {
     e.printStackTrace();
   } finally {
     if (stm != null) {
       try {
         stm.close();
       } catch (SQLException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
       }
     }
     if (connection != null) {
       try {
         connection.close();
       } catch (SQLException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
       }
     }
   }
   return false;
 }
Exemple #18
0
  /*
   * 功能:更新某一栏目参数:编写:石彦杰 2011-9-28修改:
   */
  public boolean updateLmMb(int id, String lmMb) {
    boolean returnVlue = false;
    try {
      conn = baseDAO.getConn();
      conn.createStatement()
          .executeUpdate("update lm set mb='" + lmMb.trim() + "' where id=" + String.valueOf(id));

      returnVlue = true;

    } catch (Exception ee) {
      ee.printStackTrace();
      returnVlue = false;
    }
    baseDAO.closeAll(conn);
    return returnVlue;
  }
 @Override
 public void delete(String userName, String eventId) {
   super.delete(
       Arrays.asList(
           newEqualQueryParameter("userName", userName),
           newEqualQueryParameter("eventId", eventId)));
 }
Exemple #20
0
  /*
   * 功能:删除某一子栏目参数:编写:石彦杰 2011-9-28修改:
   */
  public boolean deleteCurrentSubLm(String subName) {
    boolean returnVlue = false;
    try {
      conn = baseDAO.getConn();
      //
      // 删除栏目
      conn.createStatement().executeUpdate("delete from lm where lm2='" + subName.trim() + "'");
      returnVlue = true;

    } catch (Exception ee) {
      ee.printStackTrace();
      returnVlue = false;
    }
    baseDAO.closeAll(conn);
    return returnVlue;
  }
Exemple #21
0
  /*
   * 功能:删除所有栏目参数:编写:石彦杰 2011-9-28修改:
   */
  public boolean clear() {
    boolean returnVlue = false;
    try {
      conn = baseDAO.getConn();
      //
      // 删除栏目
      conn.createStatement().executeUpdate("delete from lm");
      returnVlue = true;

    } catch (Exception ee) {
      ee.printStackTrace();
      returnVlue = false;
    }
    baseDAO.closeAll(conn);
    return returnVlue;
  }
Exemple #22
0
 /*     */ public static String[] getSequence(String tableName, int companyID, int size)
       /*     */ {
   /* 192 */ String[] oRet = null;
   /* 193 */ Connection conn = null;
   /*     */ try {
     /* 195 */ conn = ServiceLocator.getConnection(SQLUtils.class);
     /* 196 */ BaseDAO dao = new BaseDAO();
     /* 197 */ dao.setConnection(conn);
     /* 198 */ oRet = dao.getSequence(tableName, companyID, size);
     /*     */ } catch (Exception e) {
     /* 200 */ e.printStackTrace();
     /* 201 */ return null;
     /*     */ } finally {
     /* 203 */ ServiceLocator.closeConnection(SQLUtils.class, conn);
     /*     */ }
   /* 205 */ return oRet;
   /*     */ }
Exemple #23
0
 /*
  * 功能:删除某一主栏目参数:编写:石彦杰 2011-9-28修改:
  */
 public boolean deleteRootLmById(int id) {
   boolean returnVlue = false;
   try {
     conn = baseDAO.getConn();
     // 删除父栏目
     conn.createStatement().executeUpdate("delete from lm where id=" + String.valueOf(id));
     // 删除子栏目
     conn.createStatement()
         .executeUpdate("delete from lm where lmid='" + String.valueOf(id) + "'");
     returnVlue = true;
   } catch (Exception ee) {
     ee.printStackTrace();
     returnVlue = false;
   }
   baseDAO.closeAll(conn);
   return returnVlue;
 }
Exemple #24
0
 /*
  * 功能:返回所有栏目id:单为admin所写,以使admin获取所有栏目的id
  */
 public String selectAllLmIdForAdmin() {
   String returnVlue = "";
   try {
     conn = baseDAO.getConn();
     rs = conn.createStatement().executeQuery("select id from lm ");
     int s = 1;
     while (rs.next()) {
       if (s == 1) returnVlue = String.valueOf(rs.getInt("id"));
       else returnVlue = returnVlue + "," + String.valueOf(rs.getInt("id"));
       s++;
     }
   } catch (Exception ee) {
     ee.printStackTrace();
   }
   baseDAO.closeAll(conn);
   return returnVlue;
 }
Exemple #25
0
  /*parames:optionType:true\false:connect(close)\don‘t connect(close) DB
   * 功能:返回栏目id参数:lmName--栏目名称,编写:石彦杰 2011-9-28修改:
   */
  public int selectLmId(String lmName, boolean optionType) {
    int returnVlue = 0;
    try {
      if (optionType) conn = baseDAO.getConn();

      rs = conn.createStatement().executeQuery("select id,lm from lm where lm<>''");
      while (rs.next()) {
        returnVlue = rs.getInt("id");
        if (rs.getString("lm").trim().equals(lmName)) break;
      }
    } catch (Exception ee) {
      ee.printStackTrace();
    }
    if (optionType) baseDAO.closeAll(conn);

    return returnVlue;
  }
Exemple #26
0
  /*
   * 功能:返回所有栏目的所有信息参数:编写:石彦杰 2011-9-28修改:
   */
  public List<Lm> selectAllLm() {
    List<Lm> lmList = new ArrayList<Lm>();
    Lm lm = null;
    try {
      conn = baseDAO.getConn();

      rs = conn.createStatement().executeQuery("select * from lm");
      while (rs.next()) {
        lm = new Lm();
        lm.setId(rs.getInt("id"));
        String lm1 = rs.getString("lm");
        if (lm1 == null) lm.setLm("");
        else lm.setLm(rs.getString("lm").trim());
        //
        String lm2 = rs.getString("lm2");
        if (lm2 == null) lm.setLm2("");
        else lm.setLm2(rs.getString("lm2").trim());
        //
        String lm3 = rs.getString("lm3");
        if (lm3 == null) lm.setLm3("");
        else lm.setLm3(rs.getString("lm3").trim());
        //
        String lmid = rs.getString("lmid");
        if (lmid == null) lm.setLmid("");
        else lm.setLmid(rs.getString("lmid").trim());
        //
        String mb = rs.getString("mb");
        if (mb == null) lm.setMb("");
        else lm.setMb(rs.getString("mb").trim());
        //
        String pic = rs.getString("pic");
        if (pic == null) lm.setPic("");
        else lm.setPic(rs.getString("pic").trim());
        //
        lmList.add(lm);
      }
    } catch (Exception ee) {
      ee.printStackTrace();
    }
    //
    baseDAO.closeAll(conn);

    return lmList;
  }
Exemple #27
0
 /**
  * 描述:添加所有的List的数据 2012-12-25 上午10:20:39 by ygq
  *
  * @version
  * @param list
  * @param baseDao
  */
 public static void insertAll(List list, BaseDAO baseDao) {
   if (list != null) {
     for (int i = 0; i < list.size(); i++) {
       Object o = list.get(i);
       if (null != o) {
         baseDao.insert(o);
       }
     }
   }
 }
Exemple #28
0
  /*
   * 功能:
   * 编写:石彦杰 2011-9-28
   * 修改:
   */
  public int selectCurLmPId(int id) {
    int level = 0;
    try {
      conn = baseDAO.getConn();
      rs = conn.createStatement().executeQuery("select * from lm");
      while (rs.next()) {
        if (rs.getInt("id") == id) {
          String lmid = rs.getString("lmid");
          if (lmid != null) level = Integer.parseInt(lmid);
        }
      }
    } catch (Exception ee) {
      ee.printStackTrace();
    }
    //
    baseDAO.closeAll(conn);

    return level;
  }
Exemple #29
0
 /*
  * 功能:删除某一主栏目参数:编写:石彦杰 2011-9-28修改:
  */
 public boolean deleteRootLmByName(String pName) {
   boolean returnVlue = false;
   try {
     conn = baseDAO.getConn();
     //
     // 获得父栏目的id
     int pid = selectLmId(pName, false);
     // 删除父栏目
     conn.createStatement().executeUpdate("delete from lm where lm='" + pName.trim() + "'");
     // 删除子栏目
     conn.createStatement()
         .executeUpdate("delete from lm where lmid='" + String.valueOf(pid) + "'");
     returnVlue = true;
   } catch (Exception ee) {
     ee.printStackTrace();
     returnVlue = false;
   }
   baseDAO.closeAll(conn);
   return returnVlue;
 }
Exemple #30
0
 /**
  * Delete a persistent UserProperty entity. This operation must be performed within the a database
  * transaction context for the entity's data to be permanently deleted from the persistence store,
  * i.e., database. This method uses the {@link javax.persistence.EntityManager#remove(Object)
  * EntityManager#delete} operation.
  *
  * @param entity UserProperty entity to delete
  * @throws Exception
  * @throws RuntimeException when the operation fails
  */
 public void delete(UserProperty entity) throws Exception {
   log.info("deleting UserProperty instance");
   try {
     entity = getEntityManager().getReference(UserProperty.class, entity.getId());
     super.delete(entity);
     log.info("delete successful");
   } catch (RuntimeException e) {
     log.error("delete failed", e);
     throw e;
   }
 }