Hello Guys ,I am new to Couchbase and this may be the dumb question asked 
ever. I have run a java code to connect to couchbase server and 
successfully created a document in a bucket.My question is whether I can 
run the same Java code in Android-studio/eclipse and insert the data in 
couchbase server .If it isn't possible please inform or otherwise please 
check this piece of code which I am running on android-studio
here is my piece of code in android-studio


public class MainActivity extends ActionBarActivity {

    public static final int EXP_TIME = 30;
    public static final String KEY = "key";
    public static final String VALUE = "Hello World!";
    private Socket socket;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //insert();

        // List<URI> uris = new LinkedList<URI>();

        //Boolean do_delete = false; //
       /* System.setProperty("com.couchbase.queryEnabled", "false");
        CouchbaseEnvironment environment = DefaultCouchbaseEnvironment
                .builder()
                .queryEnabled(true)
                .build();*/


        if (android.os.Build.VERSION.SDK_INT >= 9) {
            StrictMode.ThreadPolicy policy = new 
StrictMode.ThreadPolicy.Builder().permitAll().build();
            StrictMode.setThreadPolicy(policy);
        }

        Cluster cluster = CouchbaseCluster.create();
        Bucket bucket = cluster.openBucket();
        List<String> nodes = Arrays.asList("192.168.1.169", "192.168.1.169");
        cluster = CouchbaseCluster.create(nodes);
        Bucket bucket1 = cluster.openBucket("rahul");

        java.util.Date date= new java.util.Date();
        Timestamp a= new Timestamp(date.getTime());
        System.out.println(a);

        JsonObject user = JsonObject.empty()
                .put("firstname", "ravi")
                .put("lastname", "White")
                .put("job", "maths teacher")
                .put("age", 20);
        JsonDocument stored = (JsonDocument) 
bucket1.upsert(JsonDocument.create("ravi", user));

error:
07-20 20:04:53.190  31893-31893/com.example.android.couchtest 
E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.example.android.couchtest, PID: 31893
    java.lang.NoClassDefFoundError: 
com.couchbase.client.java.env.DefaultCouchbaseEnvironment
            at 
com.couchbase.client.java.CouchbaseCluster.create(CouchbaseCluster.java:42)
            at 
com.couchbase.client.java.CouchbaseCluster.create(CouchbaseCluster.java:38)
            at 
com.couchbase.client.java.CouchbaseCluster.create(CouchbaseCluster.java:30)
            at 
com.example.android.couchtest.MainActivity.onCreate(MainActivity.java:69)
            at android.app.Activity.performCreate(Activity.java:5990)
            at 
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
            at 
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
            at 
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
            at 
android.app.ActivityThread.access$800(ActivityThread.java:151)
            at 
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5257)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)


So please help me!!

-- 
You received this message because you are subscribed to the Google Groups 
"Couchbase" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to