title: java.net.UnknownHostException when using apache http client
body: <p>I am using HttpClient to connect to some third party url.Its working fine.but some times its giving java.net.UnknownHostException and also connection Reset Excetion. Please help to avoid the exception.</p>
  
  <p>Below is my code snippet.</p>
  
  <pre><code>    PostMethod post = null;
   try
   {
       for(int i =0 ; i &lt; 72 ; i++)
       {
          String url ="http://www.accuweather.com/en/in/amritsar/205593//hourly-weather-forecast/205593?hour=0";
          post = new PostMethod(url);
          post.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=" + "UTF-8");
          post.setRequestHeader("Accept-Charset", "UTF-8");
          HttpClient httpclient = new HttpClient();
          httpclient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 120000);
          httpclient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, 120000);
  
          result = httpclient.executeMethod(post);
       }
   }
   catch(Exception e){}
   finaly
   {
       post.releaseConnection();
   }
  </code></pre>
  
  <p>Belowe is the exception trace:</p>
  
  <pre><code>java.net.UnknownHostException: www.accuweather.com
      at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
      at java.net.PlainSocketImpl.connect(Unknown Source)
      at java.net.SocksSocketImpl.connect(Unknown Source)
      at java.net.Socket.connect(Unknown Source)
      at java.net.Socket.connect(Unknown Source)
      at java.net.Socket.&lt;init&gt;(Unknown Source)
      at java.net.Socket.&lt;init&gt;(Unknown Source)
      at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:80)
      at org.apache.commons.httpclient.protocol.ControllerThreadSocketFactory$1.doit(ControllerThreadSocketFactory.java:91)
      at org.apache.commons.httpclient.protocol.ControllerThreadSocketFactory$SocketTask.run(ControllerThreadSocketFactory.java:158)
      at java.lang.Thread.run(Unknown Source)
  </code></pre>