예제 #1
0
  public static Cache getCache(
      String url, String r_location, String r_lang, int r_date, String tid, String fid) {

    Cache c = null;

    try {

      DataBaseConect.cargarDriver();
      DataBaseConect.conectarAlServidor("postgres", "postgres", "localhost", "alcine-dev");
      ResultSet rs =
          DataBaseConect.exeQuery(
              "SELECT * FROM \"CACHE\" WHERE url='"
                  + url
                  + "' AND r_location='"
                  + r_location
                  + "' AND r_lang='"
                  + r_lang
                  + "' AND r_date="
                  + r_date
                  + " AND fid='"
                  + fid
                  + "' AND tid='"
                  + tid
                  + "';");
      while (rs.next()) {
        JsonObject jo = new JsonParser().parse(rs.getString("response")).getAsJsonObject();
        c =
            new Cache(
                rs.getString("url"),
                rs.getString("r_location"),
                rs.getString("r_lang"),
                rs.getInt("r_date"),
                rs.getString("tid"),
                rs.getString("fid"),
                rs.getDate("cache_date"),
                jo);
      }
      DataBaseConect.cerrarConexion();

    } catch (SQLException e) {
      e.printStackTrace();
    }

    return c;
  }