{"id":12222,"date":"2021-10-07T00:00:30","date_gmt":"2021-10-07T07:00:30","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=12222"},"modified":"2025-06-13T18:43:19","modified_gmt":"2025-06-14T01:43:19","slug":"couchbase-java-developer-walkthrough","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/couchbase-java-developer-walkthrough\/","title":{"rendered":"Get Started with Couchbase + Java [Developer Walkthrough]"},"content":{"rendered":"<p><strong>If you&#8217;re a developer who&#8217;s<\/strong> new to Couchbase, this article helps you get started.<\/p>\n<p>This weekly walkthrough series helps you understand the basics of connecting to Couchbase, shows you how to retrieve and modify data in Couchbase Server, how to use <a href=\"https:\/\/query-tutorial.couchbase.com\/tutorial\/?ref=blog\/#1\" target=\"_blank\" rel=\"noopener\">the SQL++ query language<\/a> (formerly known as N1QL) and more. This week, the example code will feature Java, and we&#8217;ll be using the Couchbase Java SDK.<\/p>\n<p><a href=\"https:\/\/developer.couchbase.com\/new-to-couchbase\/?ref=blog\" target=\"_blank\" rel=\"noopener\">Couchbase<\/a> is a distributed, <a href=\"https:\/\/www.couchbase.com\/blog\/json-database\/?ref=blog\" target=\"_blank\" rel=\"noopener\">JSON document database<\/a>. It exposes a scale-out, key-value store with managed cache for sub-millisecond data operations, purpose-built indexers for efficient queries and a powerful query engine for executing SQL-like queries.<\/p>\n<p>In this developer walkthrough, we will look at the basic features of Couchbase \u2013 both through a non-relational JSON interface and relational SQL interface. Couchbase ships with a sample database, `travel-sample`, and we&#8217;ll use this sample dataset to learn Couchbase fundamentals using the Java SDK.<\/p>\n<h2>Understanding the Travel-Sample Dataset<\/h2>\n<p>In order to gain a better understanding of what the `travel-sample` dataset looks like, feel free to <a href=\"https:\/\/docs.couchbase.com\/java-sdk\/current\/ref\/travel-app-data-model.html?ref=blog\" target=\"_blank\" rel=\"noopener\">read about it in the Java SDK documentation: Travel App Data Model<\/a>.<\/p>\n<p>Below is an entity-relationship diagram of the `travel-sample` dataset along with an accompanying data model:<\/p>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p><a href=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/10\/travel-sample-entity-relationship-diagram-couchbase.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-12226\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/10\/travel-sample-entity-relationship-diagram-couchbase.png\" alt=\"The Couchbase travel-sample dataset in an E-R diagram\" width=\"1000\" height=\"960\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/travel-sample-entity-relationship-diagram-couchbase.png 1000w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/travel-sample-entity-relationship-diagram-couchbase-300x288.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/travel-sample-entity-relationship-diagram-couchbase-768x737.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/travel-sample-entity-relationship-diagram-couchbase-20x20.png 20w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/a><\/p>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p><a href=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/10\/json-document-data-model.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-12225\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/10\/json-document-data-model.png\" alt=\"A JSON document data model in Couchbase\" width=\"538\" height=\"490\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/json-document-data-model.png 538w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/json-document-data-model-300x273.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/json-document-data-model-20x18.png 20w\" sizes=\"auto, (max-width: 538px) 100vw, 538px\" \/><\/a><\/p>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<h2>How to Use the Key-Value Get Function to Retrieve Data<\/h2>\n<p>Key-value (also known as the Couchbase Data Service) offers the simplest way to retrieve or mutate data where you know the key. A key-value store is a type of <a href=\"https:\/\/www.couchbase.com\/resources\/why-nosql\/?ref=blog\" target=\"_blank\" rel=\"noopener\">NoSQL database<\/a> that uses a simple method to store data as a collection of key-value pairs in which a key serves as the unique identifier.<\/p>\n<p><a href=\"https:\/\/www.couchbase.com\/products\/server\/?ref=blog\" target=\"_blank\" rel=\"noopener\">Couchbase Server<\/a> is a key-value store that&#8217;s agnostic to what&#8217;s stored. The example below shows you how to use the key-value `get` function in order to retrieve data from a backend.<\/p>\n<p>Before proceeding, make sure you&#8217;re familiar with the basics of authorization and connecting to a Couchbase cluster. <a href=\"https:\/\/docs.couchbase.com\/java-sdk\/current\/hello-world\/start-using-sdk.html?ref=blog\" target=\"_blank\" rel=\"noopener\">Read the &#8220;Start Using the Java SDK&#8221; section of the Couchbase documentation<\/a> if you need to catch up.<\/p>\n<p>Below are the three imports you need:<\/p>\n<pre>import com.couchbase.client.core.error.DocumentNotFoundException;\r\nimport com.couchbase.client.java.*;\r\nimport com.couchbase.client.java.kv.*;\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>Next, connect to the cluster that stores the data you want to retrieve. Because you&#8217;re using Java, first make sure you declare a class and a main method. Then create a variable for your cluster.<\/p>\n<p>In the example below, `cluster` is the name of the variable of type `var`. Using a connection string, have your program connect with the data in the backend. A Couchbase connection string is a comma-delimited list of IP addresses and\/or hostnames, optionally followed by a list of parameters. Below, `couchbase:\/\/127.0.0.1` is a simple connection string with one seed node followed by a username and password. Be sure to replace all this information with information relative to your program.<\/p>\n<pre>class Program {\r\n    public static void main(String[] args) {\r\n    var cluster = Cluster.connect(\r\n      \"couchbase:\/\/127.0.0.1\", \"username\", \"password\"\r\n    );\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>A connection to a Couchbase Server cluster is represented by a cluster object. A cluster provides access to buckets, <a href=\"https:\/\/www.couchbase.com\/blog\/scopes-and-collections-for-modern-multi-tenant-applications-couchbase-7-0\/?ref=blog\" target=\"_blank\" rel=\"noopener\">scopes and collections<\/a>, as well as various Couchbase services and management interfaces.<\/p>\n<p>After providing the connection string, username, and password above, you&#8217;re connected to a Couchbase cluster and can now connect to a Couchbase bucket and collection:<\/p>\n<pre>    var bucket = cluster.bucket(\"travel-sample\");\r\n    var collection = bucket.defaultCollection();\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>The Java `get` method allows you to retrieve a certain piece of data. Given a document&#8217;s key, you can use the `collection.get()` method to retrieve a document from a collection.<\/p>\n<p>In this example, you&#8217;re retrieving the content in the collection named `&#8221;airline_10&#8243;` in the database. Then, in order to see the result, there is a `print` statement which allows you to finish retrieving the data.<\/p>\n<pre>      try {\r\n        var result = collection.get(\"airline_10\");\r\n        System.out.println(result.toString());\r\n          }\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>Lastly, just in case the user tries to retrieve a piece of information that does not exist or is not within the bounds of the document, there is a `catch` exception to make sure there are no errors in the code.<\/p>\n<pre>      catch (DocumentNotFoundException ex) {\r\n      System.out.println(\"Document not found!\");\r\n    }\r\n  }\r\n}\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<h2>Using the Query Method to Retrieve Data<\/h2>\n<p>A query is always performed at the cluster level, specifically using the `query` method. This method takes the statement as a required argument and then allows it to provide additional options if needed.<\/p>\n<p>Once a result returns you can iterate the returned rows and\/or access the `QueryMetaData` associated with the query. If something goes wrong during the execution of the query, a derivative of the `CouchbaseException` is thrown that also provides additional context on the operation.<\/p>\n<p>Below are the five imports you need:<\/p>\n<pre>import com.couchbase.client.core.error.DocumentNotFoundException;\r\nimport com.couchbase.client.java.*;\r\nimport com.couchbase.client.java.kv.*;\r\nimport com.couchbase.client.java.json.JsonObject;\r\nimport com.couchbase.client.java.query.QueryResult;\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>Then, connect to the cluster that stores the data you want to retrieve, following similar steps as before. Be sure to replace all this information with information relative to your program.<\/p>\n<pre>class Program {\r\n    public static void main(String[] args) {\r\n    var cluster = Cluster.connect(\r\n      \"couchbase:\/\/127.0.0.1\", \"username\", \"password\"\r\n    );\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>As before, you&#8217;re connected to a Couchbase cluster and can now connect to a Couchbase bucket:<\/p>\n<pre>    var bucket = cluster.bucket(\"travel-sample\");\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>This is an example of performing a query and handling the results. The result that prints is `&#8221;Hotel: &#8220;` followed by the name, city, state and other information specific to the hotel. Only up to five rows will be printed since that is the number limit represented in the code. In order to test out different queries, try changing the name of the city in line six to any other city.<\/p>\n<pre> try {\r\n      var query = \r\n        \"SELECT h.name, h.city, h.state \" +\r\n        \"FROM `travel-sample` h \" +\r\n        \"WHERE h.type = 'hotel' \" +\r\n          \"AND h.city = 'Malibu' LIMIT 5;\";\r\n\r\n      QueryResult result = cluster.query(query);\r\n      for (JsonObject row : result.rowsAsObject()) {\r\n        System.out.println(\"Hotel: \" + row);\r\n      }\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>As before, the `catch` exception ensures there are no errors in your code. For example, if you chose a city that your database doesn&#8217;t have, this `DocumentNotFoundException` exception will print `&#8221;Document not found!&#8221;`.<\/p>\n<pre>     } catch (DocumentNotFoundException ex) {\r\n      System.out.println(\"Document not found!\");\r\n    }\r\n  }\r\n}\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<h2>How to Query with Named Parameters<\/h2>\n<p>As mentioned previously, query methods allow you to search for specific information in a database based on certain criteria. Query methods can have named or positional parameters.<\/p>\n<p>In this section, we&#8217;ll go over what named parameters are and how they are useful when calling methods with a vast number of parameters. Named parameters clearly state the name of the parameter when invoking a method. They allow users to invoke the method with a random subset of them, using default values for the rest of the parameters.<\/p>\n<p>Below are the seven imports you need:<\/p>\n<pre>import com.couchbase.client.core.error.CouchbaseException;\r\nimport com.couchbase.client.java.*;\r\nimport com.couchbase.client.java.kv.*;\r\nimport com.couchbase.client.java.json.JsonObject;\r\nimport com.couchbase.client.java.query.QueryResult;\r\nimport com.couchbase.client.java.query.QueryOptions;\r\nimport static com.couchbase.client.java.query.QueryOptions.queryOptions;\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>Then, connect to the cluster that stores the data you want to retrieve, following similar steps as before. Be sure to replace all this information with information relative to your program.<\/p>\n<pre>class Program {\r\n    public static void main(String[] args) {\r\n    var cluster = Cluster.connect(\r\n      \"couchbase:\/\/127.0.0.1\", \"username\", \"password\"\r\n    );\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>As before, you&#8217;re connected to a Couchbase cluster and can now connect to a Couchbase bucket:<\/p>\n<pre>    var bucket = cluster.bucket(\"travel-sample\");\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>The code proceeds to access the `travel-sample` database and specifically the name, city and state buckets. The `queryOptions()` method allows the customization of various SQL++ query options.<\/p>\n<p>In the code below, the result brings back data of types: `hotel` and `city: Malibu`. Since the limit is five, only up to five rows are printed. The result that&#8217;s printed is `&#8221;Hotel: &#8220;` followed by information including the name and city.<\/p>\n<pre>    try {\r\n      var query = \r\n        \"SELECT h.name, h.city, h.state \" +\r\n        \"FROM `travel-sample` h \" +\r\n        \"WHERE h.type = $type \" +\r\n          \"AND h.city = $city LIMIT 5;\";\r\n\r\n      QueryResult result = cluster.query(query,\r\n        queryOptions().parameters(\r\n          JsonObject.create()\r\n            .put(\"type\", \"hotel\")\r\n            .put(\"city\", \"Malibu\")\r\n        ));\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>The result is taken from the `travel-sample` database, specifically from the rows. The `.stream` method is used to compute elements as per the primary method without changing the original value of the JSON object.<\/p>\n<pre>          result.rowsAsObject().stream().forEach(\r\n        e-&gt; System.out.println(\r\n          \"Hotel: \" + e.getString(\"name\") + \", \" + e.getString(\"city\"))\r\n      );\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>As before, the `catch` exception ensures there are no errors in your code. For example, if you chose a city or type of place that our database does not have, this `CouchbaseException` exception will print `&#8221;Exception: &#8220;` along with the string representation of the object that is causing the error.<\/p>\n<pre>    } catch (CouchbaseException ex) {\r\n      System.out.println(\"Exception: \" + ex.toString());\r\n    }\r\n  }\r\n}\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<h2>How to Query with Positional Parameters<\/h2>\n<p>As mentioned previously, query methods can have named or positional parameters. We covered named parameters above.<\/p>\n<p>In this section, we&#8217;ll go over positional parameters and how they&#8217;re useful when calling methods with a vast number of parameters. Positional parameters allow the order of the method parameters to be replaced with placeholders.<\/p>\n<p>For example, the first placeholder is replaced with the first method parameter, the second placeholder is replaced with the second method parameter, and so on.<\/p>\n<p>Below are the seven imports you need:<\/p>\n<pre>import com.couchbase.client.core.error.CouchbaseException;\r\nimport com.couchbase.client.java.*;\r\nimport com.couchbase.client.java.kv.*;\r\nimport com.couchbase.client.java.json.JsonArray;\r\nimport com.couchbase.client.java.query.QueryResult;\r\nimport com.couchbase.client.java.query.QueryOptions;\r\nimport static com.couchbase.client.java.query.QueryOptions.queryOptions;\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>Then, connect to the cluster that stores the data you want to retrieve, following similar steps as before. Be sure to replace all this information with information relative to your program.<\/p>\n<pre>class Program {\r\n    public static void main(String[] args) {\r\n    var cluster = Cluster.connect(\r\n      \"couchbase:\/\/127.0.0.1\", \"username\", \"password\"\r\n    );\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>As before, you&#8217;re connected to a Couchbase cluster and can now connect to a Couchbase bucket:<\/p>\n<pre>    var bucket = cluster.bucket(\"travel-sample\");\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>The query below searches for the name, city and state from the `travel-sample` database taking into account specifically the type of place and the city. Later on, these are revealed as hotels in Malibu.<\/p>\n<pre>    try {\r\n      var query = \r\n        \"SELECT h.name, h.city, h.state \" +\r\n        \"FROM `travel-sample` h \" +\r\n        \"WHERE h.type = $1 \" +\r\n          \"AND h.city = $2 LIMIT 5;\";\r\n          \r\n      QueryResult result = cluster.query(query,\r\n        queryOptions().parameters(JsonArray.from(\"hotel\", \"Malibu\"))      );\r\n\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>As with the named parameters example above, the `.stream` method is used to compute elements as per the primary method without changing the original value of the JSON object.<\/p>\n<pre>      result.rowsAsObject().stream().forEach(\r\n        e-&gt; System.out.println(\r\n          \"Hotel: \" + e.getString(\"name\") + \", \" + e.getString(\"city\"))\r\n      );\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<h2>How to Use Sub-Document Lookup Operations<\/h2>\n<p><a href=\"https:\/\/docs.couchbase.com\/java-sdk\/2.7\/subdocument-operations.html?ref=blog\" target=\"_blank\" rel=\"noopener\">Sub-documents<\/a> are parts of the JSON document that you can atomically and efficiently update and retrieve.<\/p>\n<p>While full-document retrievals retrieve the entire document and full-document updates require sending the entire document, sub-document retrievals only retrieve relevant parts of a document and sub-document updates only require sending the updated portions of a document. You should use sub-document operations whenever you&#8217;re modifying only portions of a document, and full-document operations only when the contents of a document are going to change significantly.<\/p>\n<p>The sub-document operations described in this article are for <strong>key-value requests only<\/strong>; they are not related to sub-document SQL++ queries. In order to use sub-document operations you need to specify a path indicating the location of the sub-document.<\/p>\n<p>The `lookupIn` operation queries the document for a certain path(s) and returns that path(s). You have a choice of actually retrieving the document path using the `<a href=\"https:\/\/www.couchbase.com\/blog\/subdoc-explained\/\">subdoc<\/a> get` sub-document operation, or simply querying the existence of the path using the `subdoc exists` sub-document operation. The latter saves even more bandwidth by not retrieving the contents of the path if it is not needed.<\/p>\n<p>Below are the five imports you need:<\/p>\n<pre>import com.couchbase.client.core.error.DocumentNotFoundException;\r\nimport com.couchbase.client.java.*;\r\nimport com.couchbase.client.java.kv.LookupInResult;\r\nimport static com.couchbase.client.java.kv.LookupInSpec.get;\r\nimport java.util.Collections;\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>Then, connect to the cluster that stores the data you want to retrieve, following similar steps as before. Be sure to replace all this information with information relative to your program.<\/p>\n<pre>class Program {\r\n    public static void main(String[] args) {\r\n    var cluster = Cluster.connect(\r\n      \"couchbase:\/\/127.0.0.1\", \"username\", \"password\"\r\n    );\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>As before, you&#8217;re connected to a Couchbase cluster and can now connect to a Couchbase bucket:<\/p>\n<pre>    var bucket = cluster.bucket(\"travel-sample\");\r\n    var collection = bucket.defaultCollection();\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>In the code below, the `lookupIn`operation queries the `airport_1254` document for a certain path, the `geo.alt` path. This code allows us to retrieve the document path using the `subdoc get` sub-document operation: `(get(&#8220;geo.alt&#8221;))`.<\/p>\n<pre>try {\r\n      LookupInResult result = collection.lookupIn(\r\n        \"airport_1254\",\r\n        Collections.singletonList(get(\"geo.alt\"))\r\n      );\r\n\r\n      var str = result.contentAs(0, String.class);\r\n      System.out.println(\"Altitude = \" + str);\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>As before, the `catch` exception ensures there are no errors in your code. For example, if you chose a city that our database does not have, this `DocumentNotFoundException` exception will print `&#8221;Document not found!&#8221;`.<\/p>\n<pre>     } catch (DocumentNotFoundException ex) {\r\n      System.out.println(\"Document not found!\");\r\n    }\r\n  }\r\n}\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<h2>How to Use Sub-Document Mutation Operations<\/h2>\n<p>Sub-document mutation operations modify one or more paths in the document.<\/p>\n<p>The simplest of these operations is `subdoc upsert`. Just like the fulldoc-level upsert, the `subdoc upsert` operation either modifies the value of an existing path or creates it if it doesn&#8217;t exist. Likewise, the `subdoc insert` operation only adds the new value to the path if it doesn&#8217;t exist.<\/p>\n<p>Below are the eight imports you need:<\/p>\n<pre>import com.couchbase.client.core.error.subdoc.PathNotFoundException;\r\nimport com.couchbase.client.core.error.subdoc.PathExistsException;\r\nimport com.couchbase.client.java.*;\r\nimport com.couchbase.client.java.kv.LookupInResult;\r\nimport static com.couchbase.client.java.kv.LookupInSpec.get;\r\nimport static com.couchbase.client.java.kv.MutateInSpec.upsert;\r\nimport java.util.Collections;\r\nimport java.util.Arrays;\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>Then, connect to the cluster that stores the data you want to retrieve, following similar steps as before. Be sure to replace all this information with information relative to your program.<\/p>\n<pre>class Program {\r\n    public static void main(String[] args) {\r\n    var cluster = Cluster.connect(\r\n      \"couchbase:\/\/127.0.0.1\", \"username\", \"password\"\r\n    );\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>As before, you&#8217;re connected to a Couchbase cluster and can now connect to a Couchbase bucket:<\/p>\n<pre>    var bucket = cluster.bucket(\"travel-sample\");\r\n    var collection = bucket.defaultCollection();\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>In the code below, the `mutateIn` operation is used to modify the `&#8221;airline_10&#8243;` by using a fulldoc-level upsert which will create the value of an existing path with parameters `(&#8220;country&#8221;, &#8220;Canada&#8221;)`.<\/p>\n<pre>    try {\r\n      LookupInResult result = collection.lookupIn(\r\n        \"airline_10\", Collections.singletonList(get(\"country\"))\r\n      );\r\n\r\n      var str = result.contentAs(0, String.class);\r\n      System.out.println(\"Sub-doc before: \");\r\n      System.out.println(str);\r\n      \r\n    } catch (PathNotFoundException e) {\r\n      System.out.println(\"Sub-doc path not found!\");\r\n    }\r\n\r\n    try {\r\n      collection.mutateIn(\"airline_10\", Arrays.asList(\r\n        upsert(\"country\", \"Canada\")\r\n      ));\r\n    } catch (PathExistsException e) {\r\n      System.out.println(\"Sub-doc path exists!\");\r\n    }\r\n\r\n    try {\r\n      LookupInResult result = collection.lookupIn(\r\n        \"airline_10\", Collections.singletonList(get(\"country\"))\r\n      );\r\n\r\n      var str = result.contentAs(0, String.class);\r\n      System.out.println(\"Sub-doc after: \");\r\n      System.out.println(str);\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>As before, the `catch` exception ensures there are no errors in your code. For example, if you chose a document that your local computer does not have the pathway to, this `PathNotFoundException` exception will print `&#8221;Sub-doc path not found!&#8221;`.<\/p>\n<pre>    } catch (PathNotFoundException e) {\r\n      System.out.println(\"Sub-doc path not found!\");\r\n    }\r\n    \r\n  }\r\n}\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<h2>How to Use the Upsert Function<\/h2>\n<p><a href=\"https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-language-reference\/upsert.html?ref=blog\" target=\"_blank\" rel=\"noopener\">The Upsert function<\/a> is used to insert a new record or update an existing one. If the document doesn&#8217;t exist it will be created. Upsert is a combination of `insert` and `update`.<\/p>\n<p>Users executing the `upsert` statement must have the Query Update and Query Insert privileges on the target keyspace. If the statement has any returning clauses, then the Query Select privilege is also required on the keyspaces referred in the respective clauses. For more details about user roles, <a href=\"https:\/\/docs.couchbase.com\/server\/current\/learn\/security\/authorization-overview.html?ref=blog\" target=\"_blank\" rel=\"noopener\">see the Authorization documentation on role-based access control (RBAC) in Couchbase<\/a>.<\/p>\n<p>Here&#8217;s a diagram of the basic syntax for all upsert operations:<\/p>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p><a href=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/10\/upsert-basic-syntax-couchbase-database.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-12227\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/10\/upsert-basic-syntax-couchbase-database.png\" alt=\"The basic syntax of an upsert function for the Couchbase database\" width=\"675\" height=\"81\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/upsert-basic-syntax-couchbase-database.png 675w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/upsert-basic-syntax-couchbase-database-300x36.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/upsert-basic-syntax-couchbase-database-20x2.png 20w\" sizes=\"auto, (max-width: 675px) 100vw, 675px\" \/><\/a><\/p>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>Below are the nine imports you need:<\/p>\n<pre>import com.couchbase.client.core.error.subdoc.PathNotFoundException;\r\nimport com.couchbase.client.java.*;\r\nimport com.couchbase.client.java.kv.*;\r\nimport com.couchbase.client.java.kv.MutationResult;\r\nimport com.couchbase.client.java.json.JsonObject;\r\nimport com.couchbase.client.java.kv.LookupInResult;\r\nimport static com.couchbase.client.java.kv.LookupInSpec.get;\r\nimport static com.couchbase.client.java.kv.MutateInSpec.upsert;\r\nimport java.util.Collections;\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>Then, connect to the cluster that stores the data you want to retrieve, following similar steps as before. Be sure to replace all this information with information relative to your program.<\/p>\n<pre>class Program {\r\n    public static void main(String[] args) {\r\n    var cluster = Cluster.connect(\r\n      \"couchbase:\/\/127.0.0.1\", \"username\", \"password\"\r\n    );\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>As before, you&#8217;re connected to a Couchbase cluster and can now connect to a Couchbase bucket:<\/p>\n<pre>    var bucket = cluster.bucket(\"travel-sample\");\r\n    var collection = bucket.defaultCollection();\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>The `.put` method allows for the user to insert a mapping into a map. This means you can insert a specific key (and the value it is mapping to) into a particular map. If an existing key is passed then the previous value gets replaced by the new value.<\/p>\n<pre>    JsonObject content = JsonObject.create()\r\n      .put(\"country\", \"Iceland\")\r\n      .put(\"callsign\", \"ICEAIR\")\r\n      .put(\"iata\", \"FI\")\r\n      .put(\"icao\", \"ICE\")\r\n      .put(\"id\", 123)\r\n      .put(\"name\", \"Icelandair\")\r\n      .put(\"type\", \"airline\");\r\n\r\n    collection.upsert(\"airline_123\", content);\r\n      \r\n    try {\r\n      LookupInResult lookupResult = collection.lookupIn(\r\n        \"airline_123\", Collections.singletonList(get(\"name\"))\r\n      );\r\n\r\n      var str = lookupResult.contentAs(0, String.class);\r\n      System.out.println(\"New Document name = \" + str);\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>As before, the `catch` exception ensures there are no errors in your code. For example, if you chose a document that your local computer does not have the pathway to, this `PathNotFoundException` exception will print `&#8221;Document not found!&#8221;`.<\/p>\n<pre>    } catch (PathNotFoundException ex) {\r\n      System.out.println(\"Document not found!\");\r\n    }\r\n    \r\n  }\r\n}\r\n<\/pre>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<h2>Conclusion<\/h2>\n<p>I hope this introductory walkthrough helped you understand \u2013 and execute \u2013 some of the most common functions when working with Couchbase and the Java SDK. To dive into intermediate and advanced steps, <a href=\"https:\/\/docs.couchbase.com\/java-sdk\/current\/hello-world\/start-using-sdk.html?ref=blog\" target=\"_blank\" rel=\"noopener\">check out the Java SDK documentation here<\/a>.<\/p>\n<p>If you need help or need some inspiration, <a href=\"https:\/\/www.couchbase.com\/forums\/?ref=blog\" target=\"_blank\" rel=\"noopener\">check out the Couchbase Forums<\/a> and connect with like-minded developers in the community.<\/p>\n<p>As a next step, I encourage you to go through the free, online <a href=\"https:\/\/learn.couchbase.com\/store\/1288710-cb130j-couchbase-associate-java-developer-certification-course-v7?ref=blog\" target=\"_blank\" rel=\"noopener\">Couchbase Associate Java Developer Certification Course<\/a> offered by <a href=\"https:\/\/www.couchbase.com\/academy?ref=blog\" target=\"_blank\" rel=\"noopener\">Couchbase Academy<\/a>.<\/p>\n<div class=\"wp-block-spacer\" style=\"height: 30px\" aria-hidden=\"true\"><\/div>\n<div style=\"text-align: center\"><strong>Don&#8217;t just read about it, <em>build<\/em> something:&lt;br\/ &gt;<a href=\"https:\/\/www.couchbase.com\/downloads\/?ref=blog\" target=\"_blank\" rel=\"noopener\">Get started with Couchbase 7 today<\/a><\/strong><\/div>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you&#8217;re a developer who&#8217;s new to Couchbase, this article helps you get started. This weekly walkthrough series helps you understand the basics of connecting to Couchbase, shows you how to retrieve and modify data in Couchbase Server, how to [&hellip;]<\/p>\n","protected":false},"author":79065,"featured_media":12224,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1815,2381,2242,1816,1819,1818,9336,1813,1812,2201],"tags":[2312,1261,2313,1725,1903,1962,9317],"ppma_author":[9463],"class_list":["post-12222","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-best-practices-and-tutorials","category-community","category-connectors","category-couchbase-server","category-data-modeling","category-java","category-scopes-and-collections","category-security","category-n1ql-query","category-tools-sdks","tag-document-database","tag-json","tag-key-value","tag-nosql-database","tag-rbac","tag-role-based-access-control","tag-upsert"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.7.1 (Yoast SEO v25.7) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Couchbase + Java Developer Walkthrough \u2013 Get Started!<\/title>\n<meta name=\"description\" content=\"In this developer walkthrough, we will look at the basic features of Couchbase \u2013 both through a non-relational JSON interface and relational SQL interface.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.couchbase.com\/blog\/couchbase-java-developer-walkthrough\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Get Started with Couchbase + Java [Developer Walkthrough]\" \/>\n<meta property=\"og:description\" content=\"In this developer walkthrough, we will look at the basic features of Couchbase \u2013 both through a non-relational JSON interface and relational SQL interface.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/couchbase-java-developer-walkthrough\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2021-10-07T07:00:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-14T01:43:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/get-started-couchbase-java-sdk-developer-walkthrough-social.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"800\" \/>\n\t<meta property=\"og:image:height\" content=\"418\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Nirupama Suravarjjala\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/get-started-couchbase-java-sdk-developer-walkthrough-social.jpg\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nirupama Suravarjjala\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"TechArticle\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/couchbase-java-developer-walkthrough\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/couchbase-java-developer-walkthrough\/\"},\"author\":{\"name\":\"Nirupama Suravarjjala\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/bec70d9099ea0ff021938d01aeb5a033\"},\"headline\":\"Get Started with Couchbase + Java [Developer Walkthrough]\",\"datePublished\":\"2021-10-07T07:00:30+00:00\",\"dateModified\":\"2025-06-14T01:43:19+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/couchbase-java-developer-walkthrough\/\"},\"wordCount\":2231,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/couchbase-java-developer-walkthrough\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/get-started-couchbase-java-sdk-developer-walkthrough.jpg\",\"keywords\":[\"document database\",\"JSON\",\"key value\",\"NoSQL Database\",\"RBAC\",\"Role Based Access Control (RBAC)\",\"upsert\"],\"articleSection\":[\"Best Practices and Tutorials\",\"Community\",\"Connectors\",\"Couchbase Server\",\"Data Modeling\",\"Java\",\"Scopes and Collections\",\"Security\",\"SQL++ \/ N1QL Query\",\"Tools &amp; SDKs\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/couchbase-java-developer-walkthrough\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/couchbase-java-developer-walkthrough\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/couchbase-java-developer-walkthrough\/\",\"name\":\"Couchbase + Java Developer Walkthrough \u2013 Get Started!\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/couchbase-java-developer-walkthrough\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/couchbase-java-developer-walkthrough\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/get-started-couchbase-java-sdk-developer-walkthrough.jpg\",\"datePublished\":\"2021-10-07T07:00:30+00:00\",\"dateModified\":\"2025-06-14T01:43:19+00:00\",\"description\":\"In this developer walkthrough, we will look at the basic features of Couchbase \u2013 both through a non-relational JSON interface and relational SQL interface.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/couchbase-java-developer-walkthrough\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/couchbase-java-developer-walkthrough\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/couchbase-java-developer-walkthrough\/#primaryimage\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/get-started-couchbase-java-sdk-developer-walkthrough.jpg\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/get-started-couchbase-java-sdk-developer-walkthrough.jpg\",\"width\":1200,\"height\":628,\"caption\":\"Learn the basics of using Couchbase in this new developer tutorial using Java SDK code examples\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/couchbase-java-developer-walkthrough\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.couchbase.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Get Started with Couchbase + Java [Developer Walkthrough]\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"name\":\"The Couchbase Blog\",\"description\":\"Couchbase, the NoSQL Database\",\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"width\":218,\"height\":34,\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/bec70d9099ea0ff021938d01aeb5a033\",\"name\":\"Nirupama Suravarjjala\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/e69bb35c1c3b5c0146633903aec65476\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/nirupama-suravarjjala-couchbase-intern.jpeg\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/nirupama-suravarjjala-couchbase-intern.jpeg\",\"caption\":\"Nirupama Suravarjjala\"},\"url\":\"https:\/\/www.couchbase.com\/blog\/author\/nirupama-suravarjjala\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Couchbase + Java Developer Walkthrough \u2013 Get Started!","description":"In this developer walkthrough, we will look at the basic features of Couchbase \u2013 both through a non-relational JSON interface and relational SQL interface.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.couchbase.com\/blog\/couchbase-java-developer-walkthrough\/","og_locale":"en_US","og_type":"article","og_title":"Get Started with Couchbase + Java [Developer Walkthrough]","og_description":"In this developer walkthrough, we will look at the basic features of Couchbase \u2013 both through a non-relational JSON interface and relational SQL interface.","og_url":"https:\/\/www.couchbase.com\/blog\/couchbase-java-developer-walkthrough\/","og_site_name":"The Couchbase Blog","article_published_time":"2021-10-07T07:00:30+00:00","article_modified_time":"2025-06-14T01:43:19+00:00","og_image":[{"width":800,"height":418,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/get-started-couchbase-java-sdk-developer-walkthrough-social.jpg","type":"image\/jpeg"}],"author":"Nirupama Suravarjjala","twitter_card":"summary_large_image","twitter_image":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/get-started-couchbase-java-sdk-developer-walkthrough-social.jpg","twitter_misc":{"Written by":"Nirupama Suravarjjala","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"TechArticle","@id":"https:\/\/www.couchbase.com\/blog\/couchbase-java-developer-walkthrough\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/couchbase-java-developer-walkthrough\/"},"author":{"name":"Nirupama Suravarjjala","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/bec70d9099ea0ff021938d01aeb5a033"},"headline":"Get Started with Couchbase + Java [Developer Walkthrough]","datePublished":"2021-10-07T07:00:30+00:00","dateModified":"2025-06-14T01:43:19+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/couchbase-java-developer-walkthrough\/"},"wordCount":2231,"commentCount":0,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/couchbase-java-developer-walkthrough\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/get-started-couchbase-java-sdk-developer-walkthrough.jpg","keywords":["document database","JSON","key value","NoSQL Database","RBAC","Role Based Access Control (RBAC)","upsert"],"articleSection":["Best Practices and Tutorials","Community","Connectors","Couchbase Server","Data Modeling","Java","Scopes and Collections","Security","SQL++ \/ N1QL Query","Tools &amp; SDKs"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/couchbase-java-developer-walkthrough\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/couchbase-java-developer-walkthrough\/","url":"https:\/\/www.couchbase.com\/blog\/couchbase-java-developer-walkthrough\/","name":"Couchbase + Java Developer Walkthrough \u2013 Get Started!","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/couchbase-java-developer-walkthrough\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/couchbase-java-developer-walkthrough\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/get-started-couchbase-java-sdk-developer-walkthrough.jpg","datePublished":"2021-10-07T07:00:30+00:00","dateModified":"2025-06-14T01:43:19+00:00","description":"In this developer walkthrough, we will look at the basic features of Couchbase \u2013 both through a non-relational JSON interface and relational SQL interface.","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/couchbase-java-developer-walkthrough\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/couchbase-java-developer-walkthrough\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/couchbase-java-developer-walkthrough\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/get-started-couchbase-java-sdk-developer-walkthrough.jpg","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/get-started-couchbase-java-sdk-developer-walkthrough.jpg","width":1200,"height":628,"caption":"Learn the basics of using Couchbase in this new developer tutorial using Java SDK code examples"},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/couchbase-java-developer-walkthrough\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Get Started with Couchbase + Java [Developer Walkthrough]"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/blog\/#website","url":"https:\/\/www.couchbase.com\/blog\/","name":"The Couchbase Blog","description":"Couchbase, the NoSQL Database","publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"The Couchbase Blog","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","width":218,"height":34,"caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/bec70d9099ea0ff021938d01aeb5a033","name":"Nirupama Suravarjjala","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/e69bb35c1c3b5c0146633903aec65476","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/nirupama-suravarjjala-couchbase-intern.jpeg","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/nirupama-suravarjjala-couchbase-intern.jpeg","caption":"Nirupama Suravarjjala"},"url":"https:\/\/www.couchbase.com\/blog\/author\/nirupama-suravarjjala\/"}]}},"authors":[{"term_id":9463,"user_id":79065,"is_guest":0,"slug":"nirupama-suravarjjala","display_name":"Nirupama Suravarjjala","avatar_url":{"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/nirupama-suravarjjala-couchbase-intern.jpeg","url2x":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/10\/nirupama-suravarjjala-couchbase-intern.jpeg"},"author_category":"","last_name":"Suravarjjala","first_name":"Nirupama","job_title":"","user_url":"","description":"Nirupama Suravarjjala served as an intern on the Couchbase Developer Advocacy team. "}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/12222","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/users\/79065"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/comments?post=12222"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/12222\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media\/12224"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media?parent=12222"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/categories?post=12222"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/tags?post=12222"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=12222"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}