Exemplo n.º 1
0
  protected Resource createResourceFromRecord(ResultSet rs) throws SQLException {

    Resource res = this.createResource(rs);
    ResInfo resInfo = storage.getResourceInfoDAO().findById(res.getRId());
    Folder folder = storage.getFolderDAO().findById(res.getRId());
    Sinfo sinfo = storage.getSinfoDAO().findById(res.getRId());
    res.setFolder(folder);
    res.setResInfo(resInfo);
    res.setSinfo(sinfo);
    return res;
  }
Exemplo n.º 2
0
 protected synchronized boolean isHavingUrl(String url) {
   boolean isHaving = false;
   // 判断该URL是否这次任务中被抓取
   if (URLCache.findUrlInCache(url)) // 存在为true
   return true;
   // 判断该URL是否曾已被抓取
   if (storage.getSinfoDAO().isCrawlUrl(url)) return true;
   Statement stmt = null;
   String sql = "select top 1 url from spider_resource where url = '" + url + "'";
   ResultSet rs = null;
   try {
     stmt = daoHelp.getConnection().createStatement();
     rs = stmt.executeQuery(sql);
     while (rs.next()) {
       isHaving = true;
     }
     daoHelp.safeClose(rs);
     daoHelp.safeClose(stmt);
   } catch (SQLException e) {
     log.error("SQLException -> ", e);
     daoHelp.safeClose(rs);
     daoHelp.safeClose(stmt);
   } finally {
     daoHelp.safeClose(rs);
     daoHelp.safeClose(stmt);
   }
   return isHaving;
 }