Maven
Şu satırı dahil ederiz
<dependency><groupId>com.couchbase.client</groupId><artifactId>java-client</artifactId><version>3.1.6</version></dependency>
connect metodu
Örnek
Şöyle yaparız
import com.couchbase.client.java.*;import com.couchbase.client.java.kv.GetResult;import com.couchbase.client.java.kv.MutationResult;import com.couchbase.client.java.json.*;public class App{public static void main(String[] args) {Cluster cluster = Cluster.connect("192.168.0.158","Administrator","Administrator");Bucket bucket = cluster.bucket("travel-sample");Collection collection = bucket.defaultCollection();MutationResult upsertResult = collection.upsert("airbnb_1",JsonObject.create().put("name", "Tyler's AirBnB").put("country", "Canada").put("type", "hotel"));// Get a DocumentGetResult getResult = collection.get("airbnb_1");System.out.println(getResult);// Print specific field in document resultsString name = getResult.contentAsObject().getString("name");System.out.println(name);}}
Hiç yorum yok:
Yorum Gönder