aammkevin
aammkevin
2017-06-19 07:18

JAVA UnknownHostException

  • 数据
  • java
  • 服务器
String="http://192.168.1.31:8098/search/query/people?wt=json&q=  省略"
HttpClient hclient = new HttpClient();
HttpMethod method = new GetMethod(http);
hclient.executeMethod(method);
method.getResponseBodyAsString();
能正常获得数据;
但是换成公司内部服务器
String="http://isv.datahub.abc/search/query/people?wt=json&q=  省略"
久不久就会报错
java.net.UnknownHostException: isv.datahub.abc
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at java.net.Socket.connect(Socket.java:538)
    at java.net.Socket.<init>(Socket.java:434)
    at java.net.Socket.<init>(Socket.java:286)
    at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:80)
    at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocke
    ```
    (使用的是httpclient3.1)
    希望有经验的能给些思路或者建议。
    我试过method.getParams().setVirtualHost("isv.datahub.abc");
    但是没有效果
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答