When ever your java program performs a network operation the Domain name service (DNS) settings get cached inside JVM, meaning the IP address of the other machine get cached in the JVM for a period of time usually called TTL (a.k.a Time to Live) . During this time Java uses the cached IP address, even if the IP address gets changed for the machine your are trying to connecting to. Therefore if TTL is set to 300 secs and the server or resource you are trying to connect to changes its IP address the java application won’t be able to connect to it. This can be solved if we restart the JVM which will flush out the cache.
We face this issue all the time when ever we are trying to move our server cluster A to server cluster B, we need to reset or restart the clients connecting to those server clusters. For JDK 1.4 clients the default TTL settings is that it will cache the DNS for ever. The TTL value differs in version to version.
We can disable Java/JVM DNS caching by adding
on the command line starting the JVM or we can set TTL in the file java.security, which is located in the directory %JRE%\lib\security.
following shows how to configure the TTL to 30 seconds.