code: public Connection newConnection() throws IOException {
          // Throw an exception if there is an attempt to retrieve a connection from a closed factory
          if (state == State.CLOSED) {
              throw new IOException("Attempt to retrieve a connection from a closed connection factory");
          }
          // Try to establish a connection if there was no connection attempt so far
          if (state == State.NEVER_CONNECTED) {
              establishConnection();
          }
          // Retrieve the connection if it is established
          if (connection != null && connection.isOpen()) {
              return connection;
          }
          // Throw an exception if no established connection could not be retrieved
          LOGGER.error("Unable to retrieve connection");
          throw new IOException("Unable to retrieve connection");
      }
docs: <p>Gets a new connection from the factory. As this factory only
  provides one connection for every process, the connection
  is established on the first call of this method. Every
  subsequent call will return the same instance of the first
  established connection.</p>
  
  <p>In case a connection is lost, the factory will try to reestablish
  a new connection.</p>
  
  @return The connection