我想做的就是做一个upsert操作。我有一个JsonDocument,我有一个Couchbase服务器“123.456.789.1011”和一个桶里面,称为“testbucket”。现在,当我使用端口8091的IP地址打开服务器时,它要求我输入用户名和密码“uname”,“pwd”,然后输入后打开。我的桶没有任何密码。
cluster = CouchbaseCluster.create("123.456.789.101");
cluster.clusterManager("testuser","testuser123");
bucket = cluster.openBucket("testbucket");
jsonObject = JsonObject.create()
.put("Order",map);
jsonDocument = JsonDocument.create("Hello",jsonObject);
jsonDocumentResponse = bucket.upsert(jsonDocument);
这是我的代码,但问题始终是运行代码我收到错误说
ERROR spark.webserver.MatcherFilter -
com.couchbase.client.java.error.InvalidPasswordException:存储桶“testbucket”的密码不匹配。 在com.couchbase.client.java.CouchbaseAsyncCluster $ 1.call(CouchbaseAsyncCluster.java:156) 在com.couchbase.client.java.CouchbaseAsyncCluster $ 1.call(CouchbaseAsyncCluster.java:146) at rx.internal.operators.OperatorOnErrorResumeNextViaFunction $ 1.onError(OperatorOnErrorResumeNextViaFunction.java:77) at rx.internal.operators.OperatorMap $ 1.onError(OperatorMap.java:49) at rx.internal.operators.NotificationLite.accept(NotificationLite.java:147) at rx.internal.operators.OperatorObserveOn $ ObserveOnSubscriber.pollQueue(OperatorObserveOn.java:177) at rx.internal.operators.OperatorObserveOn $ ObserveOnSubscriber.access $ 000(OperatorObserveOn.java:65) at rx.internal.operators.OperatorObserveOn $ ObserveOnSubscriber $ 2.call(OperatorObserveOn.java:153) 在rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:47) at java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ScheduledThreadPoolExecutor $ ScheduledFutureTask.access $ 201(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor $ ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617) 在java.lang.Thread.run(Thread.java:745)
我是Couchbase的新手,我真的不知道该怎么做。我用Google搜索,但网上没有任何内容。甚至他们的文档也没有向我提出任何建议。我希望StackOverflow上的某个人肯定能为我找到答案。感谢。
答案 0 :(得分:0)
您似乎需要在openBucket方法中传递一个桶密码(与群集密码不同):http://docs.couchbase.com/sdk-api/couchbase-java-client-2.0.0/com/couchbase/client/java/Cluster.html#openBucket%28java.lang.String,%20java.lang.String%29
答案 1 :(得分:0)
您似乎正在尝试使用群集凭据连接存储桶。请尝试使用存储桶用户名和空密码连接到存储桶:
cluster = CouchbaseCluster.create("123.456.789.101");
bucket = cluster.openBucket("testbucket", "");