{"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\/pt\/couchbase-java-developer-walkthrough\/","title":{"rendered":"Introdu\u00e7\u00e3o ao Couchbase + Java [Passo a passo para desenvolvedores]"},"content":{"rendered":"<p><strong>Se voc\u00ea \u00e9 um desenvolvedor que est\u00e1<\/strong> novo no Couchbase, este artigo o ajudar\u00e1 a come\u00e7ar.<\/p>\n<p>Esta s\u00e9rie semanal de orienta\u00e7\u00f5es ajuda voc\u00ea a entender os fundamentos da conex\u00e3o com o Couchbase, mostra como recuperar e modificar dados no Couchbase Server, como usar o <a href=\"https:\/\/query-tutorial.couchbase.com\/tutorial\/?ref=blog\/#1\" target=\"_blank\" rel=\"noopener\">a linguagem de consulta SQL++<\/a> (anteriormente conhecido como N1QL) e muito mais. Nesta semana, o c\u00f3digo de exemplo apresentar\u00e1 Java e usaremos o Couchbase Java SDK.<\/p>\n<p><a href=\"https:\/\/developer.couchbase.com\/new-to-couchbase\/?ref=blog\" target=\"_blank\" rel=\"noopener\">Couchbase<\/a> \u00e9 um distribu\u00eddo, <a href=\"https:\/\/www.couchbase.com\/blog\/pt\/json-database\/?ref=blog\" target=\"_blank\" rel=\"noopener\">Banco de dados de documentos JSON<\/a>. Ele exp\u00f5e um armazenamento de valores-chave com escalabilidade horizontal e cache gerenciado para opera\u00e7\u00f5es de dados em menos de um mil\u00e9simo de segundo, indexadores criados especificamente para consultas eficientes e um mecanismo de consulta avan\u00e7ado para executar consultas do tipo SQL.<\/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>Entendendo o conjunto de dados de amostra de viagens<\/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\">leia sobre isso na documenta\u00e7\u00e3o do Java SDK: Modelo de dados de aplicativos de viagem<\/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>Como usar a fun\u00e7\u00e3o Key-Value Get para recuperar dados<\/h2>\n<p>O Key-value (tamb\u00e9m conhecido como Couchbase Data Service) oferece a maneira mais simples de recuperar ou alterar dados em que voc\u00ea conhece a chave. Um armazenamento de valor-chave \u00e9 um tipo de <a href=\"https:\/\/www.couchbase.com\/blog\/pt\/resources\/why-nosql\/?ref=blog\" target=\"_blank\" rel=\"noopener\">Banco de dados NoSQL<\/a> que usa um m\u00e9todo simples para armazenar dados como uma cole\u00e7\u00e3o de pares de valores-chave em que uma chave serve como identificador exclusivo.<\/p>\n<p><a href=\"https:\/\/www.couchbase.com\/blog\/pt\/products\/server\/?ref=blog\" target=\"_blank\" rel=\"noopener\">Servidor Couchbase<\/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>Antes de prosseguir, verifique se voc\u00ea conhece os conceitos b\u00e1sicos de autoriza\u00e7\u00e3o e conex\u00e3o a um cluster do Couchbase. <a href=\"https:\/\/docs.couchbase.com\/java-sdk\/current\/hello-world\/start-using-sdk.html?ref=blog\" target=\"_blank\" rel=\"noopener\">Leia a se\u00e7\u00e3o \"Comece a usar o Java SDK\" da documenta\u00e7\u00e3o do Couchbase<\/a> se voc\u00ea precisar se atualizar.<\/p>\n<p>Abaixo est\u00e3o as tr\u00eas importa\u00e7\u00f5es de que voc\u00ea precisa:<\/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>Em seguida, conecte-se ao cluster que armazena os dados que voc\u00ea deseja recuperar. Como voc\u00ea est\u00e1 usando Java, primeiro certifique-se de declarar uma classe e um m\u00e9todo principal. Em seguida, crie uma vari\u00e1vel para seu 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>Uma conex\u00e3o com um cluster do Couchbase Server \u00e9 representada por um objeto de cluster. Um cluster fornece acesso a buckets, <a href=\"https:\/\/www.couchbase.com\/blog\/pt\/scopes-and-collections-for-modern-multi-tenant-applications-couchbase-7-0\/?ref=blog\" target=\"_blank\" rel=\"noopener\">escopos e cole\u00e7\u00f5es<\/a>al\u00e9m de v\u00e1rios servi\u00e7os e interfaces de gerenciamento do Couchbase.<\/p>\n<p>Depois de fornecer a string de conex\u00e3o, o nome de usu\u00e1rio e a senha acima, voc\u00ea est\u00e1 conectado a um cluster do Couchbase e agora pode se conectar a um bucket e a uma cole\u00e7\u00e3o do Couchbase:<\/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>Usando o m\u00e9todo de consulta para recuperar dados<\/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>Abaixo est\u00e3o as cinco importa\u00e7\u00f5es de que voc\u00ea precisa:<\/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>Em seguida, conecte-se ao cluster que armazena os dados que voc\u00ea deseja recuperar, seguindo etapas semelhantes \u00e0s anteriores. Certifique-se de substituir todas essas informa\u00e7\u00f5es por informa\u00e7\u00f5es relativas ao seu programa.<\/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>Como antes, voc\u00ea est\u00e1 conectado a um cluster do Couchbase e agora pode se conectar a um bucket do Couchbase:<\/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>Como consultar com par\u00e2metros nomeados<\/h2>\n<p>Conforme mencionado anteriormente, os m\u00e9todos de consulta permitem que voc\u00ea pesquise informa\u00e7\u00f5es espec\u00edficas em um banco de dados com base em determinados crit\u00e9rios. Os m\u00e9todos de consulta podem ter par\u00e2metros nomeados ou posicionais.<\/p>\n<p>Nesta se\u00e7\u00e3o, veremos o que s\u00e3o par\u00e2metros nomeados e como eles s\u00e3o \u00fateis ao chamar m\u00e9todos com um grande n\u00famero de par\u00e2metros. Os par\u00e2metros nomeados indicam claramente o nome do par\u00e2metro ao chamar um m\u00e9todo. Eles permitem que os usu\u00e1rios invoquem o m\u00e9todo com um subconjunto aleat\u00f3rio deles, usando valores padr\u00e3o para o restante dos par\u00e2metros.<\/p>\n<p>Abaixo est\u00e3o as sete importa\u00e7\u00f5es de que voc\u00ea precisa:<\/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>Em seguida, conecte-se ao cluster que armazena os dados que voc\u00ea deseja recuperar, seguindo etapas semelhantes \u00e0s anteriores. Certifique-se de substituir todas essas informa\u00e7\u00f5es por informa\u00e7\u00f5es relativas ao seu programa.<\/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>Como antes, voc\u00ea est\u00e1 conectado a um cluster do Couchbase e agora pode se conectar a um bucket do Couchbase:<\/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>Como fazer consultas com par\u00e2metros posicionais<\/h2>\n<p>Conforme mencionado anteriormente, os m\u00e9todos de consulta podem ter par\u00e2metros nomeados ou posicionais. Abordamos os par\u00e2metros nomeados acima.<\/p>\n<p>Nesta se\u00e7\u00e3o, veremos os par\u00e2metros posicionais e como eles s\u00e3o \u00fateis ao chamar m\u00e9todos com um grande n\u00famero de par\u00e2metros. Os par\u00e2metros posicionais permitem que a ordem dos par\u00e2metros do m\u00e9todo seja substitu\u00edda por espa\u00e7os reservados.<\/p>\n<p>Por exemplo, o primeiro espa\u00e7o reservado \u00e9 substitu\u00eddo pelo primeiro par\u00e2metro de m\u00e9todo, o segundo espa\u00e7o reservado \u00e9 substitu\u00eddo pelo segundo par\u00e2metro de m\u00e9todo e assim por diante.<\/p>\n<p>Abaixo est\u00e3o as sete importa\u00e7\u00f5es de que voc\u00ea precisa:<\/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>Em seguida, conecte-se ao cluster que armazena os dados que voc\u00ea deseja recuperar, seguindo etapas semelhantes \u00e0s anteriores. Certifique-se de substituir todas essas informa\u00e7\u00f5es por informa\u00e7\u00f5es relativas ao seu programa.<\/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>Como antes, voc\u00ea est\u00e1 conectado a um cluster do Couchbase e agora pode se conectar a um bucket do Couchbase:<\/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>Como usar opera\u00e7\u00f5es de pesquisa de subdocumentos<\/h2>\n<p><a href=\"https:\/\/docs.couchbase.com\/java-sdk\/2.7\/subdocument-operations.html?ref=blog\" target=\"_blank\" rel=\"noopener\">Subdocumentos<\/a> s\u00e3o partes do documento JSON que voc\u00ea pode atualizar e recuperar de forma at\u00f4mica e eficiente.<\/p>\n<p>Enquanto as recupera\u00e7\u00f5es de documentos completos recuperam o documento inteiro e as atualiza\u00e7\u00f5es de documentos completos exigem o envio do documento inteiro, as recupera\u00e7\u00f5es de subdocumentos recuperam apenas partes relevantes de um documento e as atualiza\u00e7\u00f5es de subdocumentos exigem apenas o envio das partes atualizadas de um documento. Voc\u00ea deve usar as opera\u00e7\u00f5es de subdocumento sempre que estiver modificando apenas partes de um documento e as opera\u00e7\u00f5es de documento completo somente quando o conte\u00fado de um documento for alterado significativamente.<\/p>\n<p>As opera\u00e7\u00f5es de subdocumento descritas neste artigo s\u00e3o para <strong>somente solicita\u00e7\u00f5es de valor-chave<\/strong>Elas n\u00e3o est\u00e3o relacionadas a consultas SQL++ de subdocumentos. Para usar opera\u00e7\u00f5es de subdocumento, voc\u00ea precisa especificar um caminho que indique o local do subdocumento.<\/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\/pt\/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>Abaixo est\u00e3o as cinco importa\u00e7\u00f5es de que voc\u00ea precisa:<\/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>Em seguida, conecte-se ao cluster que armazena os dados que voc\u00ea deseja recuperar, seguindo etapas semelhantes \u00e0s anteriores. Certifique-se de substituir todas essas informa\u00e7\u00f5es por informa\u00e7\u00f5es relativas ao seu programa.<\/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>Como antes, voc\u00ea est\u00e1 conectado a um cluster do Couchbase e agora pode se conectar a um bucket do Couchbase:<\/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>Como usar opera\u00e7\u00f5es de muta\u00e7\u00e3o de subdocumentos<\/h2>\n<p>As opera\u00e7\u00f5es de muta\u00e7\u00e3o de subdocumento modificam um ou mais caminhos no documento.<\/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>Abaixo est\u00e3o as oito importa\u00e7\u00f5es de que voc\u00ea precisa:<\/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; import static com.couchbase.client.java.kv.MutateInSpec.upsert;\r\nimportar 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>Em seguida, conecte-se ao cluster que armazena os dados que voc\u00ea deseja recuperar, seguindo etapas semelhantes \u00e0s anteriores. Certifique-se de substituir todas essas informa\u00e7\u00f5es por informa\u00e7\u00f5es relativas ao seu programa.<\/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>Como antes, voc\u00ea est\u00e1 conectado a um cluster do Couchbase e agora pode se conectar a um bucket do Couchbase:<\/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>Como usar a fun\u00e7\u00e3o Upsert<\/h2>\n<p><a href=\"https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-language-reference\/upsert.html?ref=blog\" target=\"_blank\" rel=\"noopener\">A fun\u00e7\u00e3o Upsert<\/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\">consulte a documenta\u00e7\u00e3o de Autoriza\u00e7\u00e3o sobre controle de acesso baseado em fun\u00e7\u00e3o (RBAC) no Couchbase<\/a>.<\/p>\n<p>Aqui est\u00e1 um diagrama da sintaxe b\u00e1sica para todas as opera\u00e7\u00f5es de upsert:<\/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>Abaixo est\u00e3o as nove importa\u00e7\u00f5es de que voc\u00ea precisa:<\/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; import 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>Em seguida, conecte-se ao cluster que armazena os dados que voc\u00ea deseja recuperar, seguindo etapas semelhantes \u00e0s anteriores. Certifique-se de substituir todas essas informa\u00e7\u00f5es por informa\u00e7\u00f5es relativas ao seu programa.<\/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>Como antes, voc\u00ea est\u00e1 conectado a um cluster do Couchbase e agora pode se conectar a um bucket do Couchbase:<\/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>Conclus\u00e3o<\/h2>\n<p>Espero que este passo a passo introdut\u00f3rio tenha ajudado voc\u00ea a entender - e executar - algumas das fun\u00e7\u00f5es mais comuns ao trabalhar com o Couchbase e o Java SDK. Para se aprofundar nas etapas intermedi\u00e1rias e avan\u00e7adas, <a href=\"https:\/\/docs.couchbase.com\/java-sdk\/current\/hello-world\/start-using-sdk.html?ref=blog\" target=\"_blank\" rel=\"noopener\">Confira a documenta\u00e7\u00e3o do Java SDK aqui<\/a>.<\/p>\n<p>Se voc\u00ea precisar de ajuda ou de inspira\u00e7\u00e3o, <a href=\"https:\/\/www.couchbase.com\/blog\/pt\/forums\/?ref=blog\" target=\"_blank\" rel=\"noopener\">Confira os f\u00f3runs do Couchbase<\/a> e se conectar com desenvolvedores que pensam da mesma forma na comunidade.<\/p>\n<p>Como pr\u00f3xima etapa, eu o encorajo a ler o guia on-line gratuito <a href=\"https:\/\/learn.couchbase.com\/store\/1288710-cb130j-couchbase-associate-java-developer-certification-course-v7?ref=blog\" target=\"_blank\" rel=\"noopener\">Curso de Certifica\u00e7\u00e3o de Desenvolvedor Java Associado do Couchbase<\/a> oferecido por <a href=\"https:\/\/www.couchbase.com\/blog\/pt\/academy\/?ref=blog\" target=\"_blank\" rel=\"noopener\">Academia Couchbase<\/a>.<\/p>\n<div class=\"wp-block-spacer\" style=\"height: 30px\" aria-hidden=\"true\"><\/div>\n<div style=\"text-align: center\"><strong>N\u00e3o se limite a ler sobre o assunto, <em>construir<\/em> algo:<br \/><a href=\"https:\/\/www.couchbase.com\/blog\/pt\/downloads\/?ref=blog\" target=\"_blank\" rel=\"noopener\">Comece a usar o Couchbase 7 hoje mesmo<\/a><\/strong><\/div>\n<div class=\"wp-block-spacer\" style=\"height: 15px\" aria-hidden=\"true\"><\/div>\n<p>&nbsp;<\/p>","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>","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.9 (Yoast SEO v25.9) - 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\/pt\/couchbase-java-developer-walkthrough\/\" \/>\n<meta property=\"og:locale\" content=\"pt_BR\" \/>\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\/pt\/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 minutos\" \/>\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\":\"pt-BR\",\"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\":\"pt-BR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/couchbase-java-developer-walkthrough\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@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\":\"pt-BR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@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\":\"pt-BR\",\"@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\/pt\/author\/nirupama-suravarjjala\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Couchbase + Java Developer Walkthrough \u2013 Get Started!","description":"Neste passo a passo para desenvolvedores, veremos os recursos b\u00e1sicos do Couchbase, tanto por meio de uma interface JSON n\u00e3o relacional quanto por meio de uma interface SQL relacional.","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\/pt\/couchbase-java-developer-walkthrough\/","og_locale":"pt_BR","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\/pt\/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 minutos"},"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":"pt-BR","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":"Neste passo a passo para desenvolvedores, veremos os recursos b\u00e1sicos do Couchbase, tanto por meio de uma interface JSON n\u00e3o relacional quanto por meio de uma interface SQL relacional.","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/couchbase-java-developer-walkthrough\/#breadcrumb"},"inLanguage":"pt-BR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/couchbase-java-developer-walkthrough\/"]}]},{"@type":"ImageObject","inLanguage":"pt-BR","@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":"Blog do Couchbase","description":"Couchbase, o banco de dados NoSQL","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":"pt-BR"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"Blog do Couchbase","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"pt-BR","@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":"pt-BR","@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\/pt\/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\/pt\/wp-json\/wp\/v2\/posts\/12222","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/users\/79065"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/comments?post=12222"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/posts\/12222\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/media\/12224"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/media?parent=12222"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/categories?post=12222"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/tags?post=12222"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/ppma_author?post=12222"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}