public SiteInternal find(URL siteURL) {
   SiteInternal site = null;
   Statement st = null;
   ResultSet rs = null;
   try {
     Connection c = dbUtil.getConnection();
     st = c.createStatement();
     rs =
         st.executeQuery(
             "select * from jspider_site where host = '"
                 + siteURL.getHost()
                 + "' and port = "
                 + siteURL.getPort());
     if (rs.next()) {
       site = createSiteFromRecord(rs);
     } else {
       return null;
     }
   } catch (SQLException e) {
     log.error("SQLException", e);
   } finally {
     dbUtil.safeClose(rs, log);
     dbUtil.safeClose(st, log);
   }
   return site;
 }
 public void save(int id, SiteInternal site) {
   StringBuffer sb = new StringBuffer();
   Connection connection = dbUtil.getConnection();
   Statement st = null;
   sb.append("update jspider_site set ");
   sb.append("handle=");
   sb.append(DBUtil.format(site.mustHandle()));
   sb.append(",robotstxthandled=");
   sb.append(DBUtil.format(site.isRobotsTXTHandled()));
   sb.append(",usecookies=");
   sb.append(DBUtil.format(site.getUseCookies()));
   sb.append(",useproxy=");
   sb.append(DBUtil.format(site.getUseProxy()));
   sb.append(",state=");
   sb.append(DBUtil.format(site.getState()));
   sb.append(",obeyrobotstxt=");
   sb.append(DBUtil.format(site.getObeyRobotsTXT()));
   sb.append(",basesite=");
   sb.append(DBUtil.format(site.isBaseSite()));
   sb.append(",useragent=");
   sb.append(DBUtil.format(site.getUserAgent()));
   sb.append(" where id = ");
   sb.append(DBUtil.format(id));
   try {
     st = connection.createStatement();
     st.executeUpdate(sb.toString());
   } catch (SQLException e) {
     log.error("SQLException", e);
   } finally {
     dbUtil.safeClose(st, log);
   }
 }
 public void create(int id, SiteInternal site) {
   Connection connection = dbUtil.getConnection();
   Statement st = null;
   StringBuffer sb = new StringBuffer();
   sb.append("insert into jspider_site (");
   sb.append("id,");
   sb.append("host,");
   sb.append("port,");
   sb.append("handle,");
   sb.append("robotstxthandled,");
   sb.append("usecookies,");
   sb.append("useproxy,");
   sb.append("state,");
   sb.append("obeyrobotstxt,");
   sb.append("basesite,");
   sb.append("useragent");
   sb.append(") values (");
   sb.append(DBUtil.format(id));
   sb.append(",");
   sb.append(DBUtil.format(site.getHost()));
   sb.append(",");
   sb.append(DBUtil.format(site.getPort()));
   sb.append(",");
   sb.append(DBUtil.format(site.mustHandle()));
   sb.append(",");
   sb.append(DBUtil.format(site.isRobotsTXTHandled()));
   sb.append(",");
   sb.append(DBUtil.format(site.getUseCookies()));
   sb.append(",");
   sb.append(DBUtil.format(site.getUseProxy()));
   sb.append(",");
   sb.append(DBUtil.format(site.getState()));
   sb.append(",");
   sb.append(DBUtil.format(site.getObeyRobotsTXT()));
   sb.append(",");
   sb.append(DBUtil.format(site.isBaseSite()));
   sb.append(",");
   sb.append(DBUtil.format(site.getUserAgent()));
   sb.append(")");
   try {
     st = connection.createStatement();
     st.executeUpdate(sb.toString());
   } catch (SQLException e) {
     log.error("SQLException", e);
   } finally {
     dbUtil.safeClose(st, log);
   }
 }
 public SiteInternal[] findAll() {
   ArrayList al = new ArrayList();
   Statement st = null;
   ResultSet rs = null;
   try {
     Connection c = dbUtil.getConnection();
     st = c.createStatement();
     rs = st.executeQuery("select * from jspider_site");
     while (rs.next()) {
       al.add(createSiteFromRecord(rs));
     }
   } catch (SQLException e) {
     log.error("SQLException", e);
   } finally {
     dbUtil.safeClose(rs, log);
     dbUtil.safeClose(st, log);
   }
   return (SiteInternal[]) al.toArray(new SiteInternal[al.size()]);
 }