Esempio n. 1
0
 private void coba() {
   try {
     String out =
         java.net.URLEncoder.encode(
             "Capt. Scott reached Scott Island in December 1902  -.edu -nltk -linguistics -nlp -github -entailment",
             "utf-8");
     System.out.println(out);
   } catch (UnsupportedEncodingException e) {
     e.printStackTrace();
   }
 }
Esempio n. 2
0
  // ambil id dan Hipotesis
  private void prosesH() {
    ResultSet rs = null;
    try {
      // pSel.setString(1,"1");
      rs = pSel.executeQuery();
      String h = "";
      int id = -1;
      while (rs.next()) { // pasti dapat 1
        id = rs.getInt(1);
        h = rs.getString(2);
        System.out.println(id + ":" + h);
      }

      if (h.equals("")) {
        // nggak boleh kosong!
        System.out.println("Error: h kosong");
        return;
      }

      // konversi H ke bentuk valid URL
      // contoh,
      // input:
      // Capt. Scott reached Scott Island in December 1902  -.edu -nltk -linguistics -nlp -github
      // -entailment
      // output:
      // Capt.+Scott+reached+Scott+Island+in+December+1902++-.edu+-nltk+-linguistics+-nlp+-github+-entailment&oq=Capt.+Scott+reached+Scott+Island+in+December+1902++-.edu+-nltk+-linguistics+-nlp+-github+-entailment
      String parH = java.net.URLEncoder.encode(h, "utf-8");

      // panggil API google, hasilnya simpan
      String hasilSE = urlReader(parH);
      // System.out.println("hasil crawl:"+hasilSE);

      // save ke DB

      // "update rte3_babak2 " +
      // "set hasilsearch=?,
      //     isproses=1,
      //     timestamp=? where id=?");

      java.util.Date date = new Date();
      Timestamp timestamp = new Timestamp(date.getTime());
      pIns.setString(1, hasilSE);
      pIns.setTimestamp(2, timestamp);
      pIns.setInt(3, id);
      pIns.execute();
      rs.close();
      // koneksi ditutup di method close()
    } catch (Exception e) {
      e.printStackTrace();
    }
  }