Hello folks,
i am trying to creat Connection to Elasticsearch using Client API, and i want to handle Cases , if the Host is not existing or unknown or the Port ist wrong or not existing or empty,
how to write that in java ,
here is my Start,
try {
client = new PreBuiltTransportClient(Settings.EMPTY)
.addTransportAddress(new TransportAddress(InetAddress
.getByName("localhost"), 9300));
} catch (UnknownHostException ex) {
System.out.println("faild host " + ex.getMessage());
client.close();
}catch(UnknownTransportNummber nr){
System.out.println("faild port" + nr.getMessage());
}
i want to check and handle the localhost , and PortNummber, is there any tutorial or Advice how to do that??
I found "UnknownHostException" to handle the Host error , is there any Exception to handle the Port error something like "UnknownTransportNummber " or "UnknownPort" ??
thx