简体   繁体   English

Cloudant AuthCookie不能为空

[英]Cloudant AuthCookie may not be null

I am currently trying to add entries into Cloudant using this link: 我目前正在尝试使用此链接将条目添加到Cloudant:
https://github.com/cloudant/java-cloudant#installation-and-usage https://github.com/cloudant/java-cloudant#installation-and-usage

Below is my code 下面是我的代码

package sample;

import java.util.List;

import com.cloudant.client.api.CloudantClient;

public class Cloudant {
    public static void main (String[] args){

    String password = System.getProperty("gffgasdas");
    CloudantClient client = new CloudantClient("wiz.cloudant.com",password);



    System.out.println("Connected to Cloudant");
    System.out.println("Server Version: " + client.serverVersion());

    List<String> databases = client.getAllDbs();
    System.out.println("All my databases : ");
    for ( String db : databases ) {
        System.out.println(db);
        }
    }
}

I am getting this error: 我收到此错误:

Exception in thread "main" java.lang.IllegalArgumentException: AuthCookie may not be null.
    at org.lightcouch.internal.CouchDbUtil.assertNotEmpty(Unknown Source)
    at com.cloudant.client.api.CloudantClient.<init>(Unknown Source)
    at sample.Cloudant.main(Cloudant.java:11)

I have all the necessary important imports. 我拥有所有必要的重要进口商品。 Any help would be appreciated thanks. 任何帮助,将不胜感激谢谢。

I'm not sure you're using the right constructor. 我不确定您使用的是正确的构造函数。 It looks like you need to use the three-argument constructor CloudantClient(cloudantAccountName, username, password) . 看来您需要使用三参数构造函数CloudantClient(cloudantAccountName, username, password)

Your line: 您的电话:

CloudantClient client = new CloudantClient("wiz.cloudant.com",password);

Needs to be: 需要是:

CloudantClient client = new CloudantClient("wiz", "wiz", password);

The two-argument version assumes you are passing a cookie rather than a password. 包含两个参数的版本假定您传递的是cookie而不是密码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM