2014-10-31 128 views
0

我的動物園管理員實例的服務器主機上運行:端口動物園管理員的Java用戶名密碼

如果我想通過Web瀏覽器訪問它,我首先必須通過用戶名/密碼登錄,然後只能夠進入我的動物園管理員實例。

但是在Java中,當我試試這個:

String hostPort = "host:port"; 
    System.out.println("Trying to connect"); 
    ZooKeeper zk = new ZooKeeper(hostPort, 3000, this); 
    String data = "some byte data"; 
    try { 
     zk.create("https://stackoverflow.com/a/b", data.getBytes(), null, CreateMode.PERSISTENT); 
    } catch (Exception e) { 
     System.out.println(e.getMessage()); 
    } 

我得到以下輸出:

Trying to connect 
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". 
SLF4J: Defaulting to no-operation (NOP) logger implementation 
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. 
KeeperErrorCode = ConnectionLoss for /a/b 

我相信,那是因爲我不能夠提供的用戶名/密碼服務器認證。 如何在java中實現我想要的功能?

回答

1

不需要服務器驗證。事實上,我通過不正確的需要驗證的接口進行連接。