2012-05-02 45 views
2
import com.fourspaces.couchdb.Session; 
import com.fourspaces.couchdb.Database; 
import com.fourspaces.couchdb.Document; 
import com.fourspaces.couchdb.View; 
import com.fourspaces.couchdb.ViewResults; 
import com.fourspaces.couchdb.CouchResponse; 
import com.fourspaces.couchdb.AdHocView; 

public class temporaryViews 
{ 
public static void main(String[] args) throws Exception 
{ 

    Session s = new Session("localhost",5984,"monil","monil",false,false); 
    Database db = s.getDatabase("foodb"); 

// Running a view 
     ViewResults resultAdHoc = db.adhoc("function (doc) {emit(null, doc);}"); 
     System.out.println(resultAdHoc.getResults().size()); 
    } 
} 

我試着用上面的代碼來創建臨時視圖中使用CouchDb4J API不工作,我得到臨時視圖是Java

Exception in thread "main" java.lang.NullPointerException 
at temporaryViews.main(temporaryViews.java:53) 

請建議的解決方案

在此先感謝

回答

1

我面臨同樣的問題。嘗試EKTROP api,這將幫助你。

+0

我需要使用Couchdb4j api創建視圖,任何人都可以向我建議解決方案 – monil

1

我在這裏面臨同樣的問題(無法創建視圖)。臨時解決方法是更新服務器配置。在couch.ini文件修改authentication_handlers:

[httpd] 
port=8008 
authentication_handlers = {couch_httpd_oauth, oauth_authentication_handler}, 
    {couch_httpd_auth, null_authentication_handler}, 
    {couch_httpd_auth, cookie_authentication_handler} 

重要的一個是null_authentication_handler,但要注意:由於https://wiki.apache.org/couchdb/Security_Features_Overview#Authentication狀態,這是發展的目的。

希望有人會找到一個真正的解決方案(適用於生產環境)。