2013-10-17 3 views
0

H2는 여러 네트워크 인터페이스를 어떻게 처리합니까? 현재 IP가있는 두 개의 인터페이스가 발견되면 오류 메시지를 반환하는 getOwnIpAddress 함수를 사용하여 한 컴퓨터에서 두 개의 ips를 사용할 수 없습니다.H2 다중 네트워크 인터페이스

private String getOwnIpAddress() 
    { 
     ArrayList<String> ipAddresses = new ArrayList<>(); 
     try 
     { 
      /*find out my own ip address*/ 
      Enumeration<NetworkInterface> networkInterfaces; 
      networkInterfaces = NetworkInterface.getNetworkInterfaces(); 
      for (NetworkInterface netint : Collections.list(networkInterfaces)) 
      { 
       Enumeration<InetAddress> inetAddresses = netint.getInetAddresses(); 
       for (InetAddress inetAddress : Collections.list(inetAddresses)) 
       { 
        if (isIPAddress(inetAddress.getHostAddress()) 
          && !inetAddress.getHostAddress().equals("127.0.0.1")) 
        { 
         ipAddresses.add(inetAddress.getHostAddress()); 
        } 
       } 
      } 
      if (ipAddresses.size() > 1) 
      { 
       DialogMessage.showMessage(null, Resource.getResourceString("tooManyInterfacesError"), "", 
         JOptionPane.ERROR_MESSAGE); 
       Main.quit(); 
      } 
      else if (ipAddresses.size() > 0) 
      { 
       return ipAddresses.get(0); 
      } 
      else 
      { 
       return null; 
      } 
     } 
     catch (SocketException ex) 
     { 
      ex.printStackTrace(); 
     } 
     return null; 
    } 

H2가 하나의 IP를 선호하도록 할 수 있습니까? 또는 auto_server 모드에서 H2로 처리 할 수 ​​있습니까?

+0

이것이 도움이 될지 모르겠지만 시스템 속성'h2.bindAddress'를 사용해 보셨습니까? [the javadocs] (http://h2database.com/javadoc/org/h2/constant/SysProperties.html#h2.bindAddress)도 참고하십시오. –

답변

0

시스템 속성 h2.bindAddress을 사용할 수 있습니다.

+0

필자의 경우 auto_server 모드를 사용하여 특정 서버 IP가 내 프로그램에 투명하도록 h2.bindAddress = "localhost"를 사용합니다. 나는 H2가 Lan과 Wan 인터페이스의 경우에 어떻게 동작 할 것인가를 이해할 수 없다. H2는 더 빠른 Lan 인터페이스를 사용할만큼 똑똑 할 것인가? 나는 이것을 테스트 할 것이지만 그 주제에 대한 공식 문서 나 정교함은 매우 흥미로울 것이다. 고맙습니다 –

관련 문제