Cloudant AuthCookie可能不为空

时间:2015-03-23 21:14:51

标签: java maven cloudant

我目前正在尝试使用此链接向Cloudant添加条目:
https://github.com/cloudant/java-cloudant#installation-and-usage

以下是我的代码

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);
        }
    }
}

我收到此错误:

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)

我拥有所有必要的重要进口产品。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

我不确定你是否正在使用正确的构造函数。看起来您需要使用三参数构造函数CloudantClient(cloudantAccountName, username, password)

你的专栏:

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

需要:

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

双参数版本假设您传递的是cookie而不是密码。