how do I REALLY set connection timeout in JAVA

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • how do I REALLY set connection timeout in JAVA

      Hi everybody

      I'm using the classes ConnectionConfiguration, ConnectionFactory and Connection from the org.palo.api package to open a connection to a Palo Server.

      Source Code

      1. ConnectionConfiguration connectionConfiguration = new ConnectionConfiguration(paloServer, Integer.toString(paloPort));connectionConfiguration.setPassword(paloPassword);connectionConfiguration.setUser(paloUser);connectionConfiguration.setLoadOnDemand(true);connectionConfiguration.setTimeout(timeOut);
      2. Connection c = ConnectionFactory.getInstance().newConnection(connectionConfiguration);

      This works quite fine. But then I tried to change the timeout to 1 millisecond and connect to a nonexisting host. Now it seems as my timeout is ignored, because it takes several seconds until it throws the exception

      com.tensegrity.palojava.PaloException: Could not connect to palo server at host '' on port '7777'

      It's not even a timeout exceeded exception. Am I using the timeout wrong, is it a bug or am I completely misunderstanding the whole timeout-thing? Is it even a timeout for opening the connection or is it for the queries that will follow?

      As you can see, I'm quite confused :huh: So could anybody please help me?

      Thank you a lot!