{"id":55885,"date":"2018-03-05T15:00:02","date_gmt":"2018-03-05T13:00:02","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=55885"},"modified":"2018-03-05T10:50:16","modified_gmt":"2018-03-05T08:50:16","slug":"mongodb-close-isclosed-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-close-isclosed-example\/","title":{"rendered":"MongoDB close() and isClosed() Example"},"content":{"rendered":"<p>Hello readers, these days to increase the system capacity it is important to instruct the Mongo database to close a connection and free the associated database resources. In Mongo world, it is pretty straightforward and in this tutorial, we will see the <code>cursor.close()<\/code> and <code>cursor.isClosed()<\/code> methods available in the Mongo database. Let\u2019s study in brief the usage of each method.<\/p>\n<h2>1. Introduction<\/h2>\n<p>If you have installed the MongoDB application (<em>version 3.6<\/em>) on Windows or Ubuntu operating system and you wish to learn the <code>cursor.close()<\/code> and <code>cursor.isClosed()<\/code> methods then follow the below steps. It is very simple. But before moving further let&#8217;s take a look at the Mongo database and its features.<\/p>\n<h3>1.1 What is MongoDB?<\/h3>\n<ul>\n<li>MongoDB is a high-performance <em>NoSQL database<\/em> where each database has collections which in turn has documents. Each document has a different number of fields, size, content, and is stored in a JSON-like format (i.e. Binary JSON (<a href=\"https:\/\/en.wikipedia.org\/wiki\/BSON\" target=\"_blank\" rel=\"noopener\">BSN<\/a>)<\/li>\n<li>The documents in MongoDB doesn\u2019t need to have a schema defined beforehand. Instead, the fields (i.e. <em>records<\/em>) can be created on the go<\/li>\n<li>Data model available within the MongoDB allows developers to represent the hierarchical relationships, store arrays, and other more complex structures easily<\/li>\n<li>This NoSQL solution often comes with embedding, auto-sharding, and onboard replication for better scalability and high availability<\/li>\n<\/ul>\n<h4>1.1.1 Why MongoDB?<\/h4>\n<ul>\n<li>As a NoSQL type database, MongoDB stores the data in the form of a document. Thus, MongoDB offers more flexibility<\/li>\n<li>This database supports search by field-name, range queries, and the regular expressions. It often provides queries to return the particular fields inside the documents<\/li>\n<li>MongoDB offers <em>indexes<\/em> to improve the <em>search performance<\/em> within the NoSQL database<\/li>\n<li>To offer horizontal scalability, MongoDB uses sharding by splitting the data across the many MongoDB occurrences<\/li>\n<li><strong>Replication<\/strong>: MongoDB can give high availability with the replica sets<\/li>\n<\/ul>\n<h3>1.2 What is a Cursor in MongoDB?<\/h3>\n<p>In Mongo world, a <strong>cursor<\/strong> is an object that allows developers to iterate through the documents of a Mongo collection. The behavior of cursor allows an automatic iteration across the results of the query; however, developers can explicitly go through the items returned in the cursor object. The below diagram lists <code>4<\/code> documents where the Mongo <em>cursor<\/em> will point to the first document and then iterate through all the other documents of a collection.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p><figure id=\"attachment_55841\" aria-describedby=\"caption-attachment-55841\" style=\"width: 673px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-archi-guide-1.jpg\"><img decoding=\"async\" class=\"size-full wp-image-55841\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-archi-guide-1.jpg\" alt=\"Fig. 1: Pictorial representation of a Cursor in Mongo collection\" width=\"673\" height=\"492\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-archi-guide-1.jpg 673w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/mongodb-cbs-project-archi-guide-1-300x219.jpg 300w\" sizes=\"(max-width: 673px) 100vw, 673px\" \/><\/a><figcaption id=\"caption-attachment-55841\" class=\"wp-caption-text\">Fig. 1: Pictorial representation of a Cursor in Mongo collection<\/figcaption><\/figure><\/p>\n<h4>1.2.1 Why Cursor in MongoDB?<\/h4>\n<p><em>Cursor<\/em> offers:<\/p>\n<ul>\n<li>A true snapshot of a system i.e. it returns the data in batches and increases the database performance<\/li>\n<li>It saves system memory by allowing batch inserts and updates<\/li>\n<li>Intelligibility and Clarity on the ad-hoc and complex queries of the sequential nature having large result sets and low consistency requirements<\/li>\n<li>Openness to work on small batches of data as developers don\u2019t need to wait for the processing and download of the complete record-set<\/li>\n<\/ul>\n<p>Now, let\u2019s move further and understand how to handle the <code>cursor.close()<\/code> and <code>cursor.isClosed()<\/code> methods provided by the Mongo database.<\/p>\n<h3>1.3 close() method in the Mongo database<\/h3>\n<p>In the Mongo universe, the <code><a href=\"https:\/\/docs.mongodb.com\/manual\/reference\/method\/cursor.close\/\" target=\"_blank\" rel=\"noopener\">close()<\/a><\/code> method instructs the server to close a <a href=\"https:\/\/docs.mongodb.com\/manual\/tutorial\/iterate-a-cursor\/#read-operations-cursors\" target=\"_blank\" rel=\"noopener\">cursor<\/a> and free the associated server resources. The server will automatically close the cursors that have no remaining results and the cursors that have been idle for a time. Here is what the query syntax will look like.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Mongo database close() Syntax<\/em><\/span><\/p>\n<pre class=\"brush:bash;wrap-lines:false;\">&gt; db.collection_name.find(&lt;query&gt;).close()\r\n<\/pre>\n<p>where:<\/p>\n<ul>\n<li>The <strong>query<\/strong> is the query string on which the documents are retrieved from the collection<\/li>\n<\/ul>\n<h3>1.4 isClosed() method in the Mongo database<\/h3>\n<p>In the Mongo universe, the <code><a href=\"https:\/\/docs.mongodb.com\/manual\/reference\/method\/cursor.isClosed\/\" target=\"_blank\" rel=\"noopener\">isClosed()<\/a><\/code> method returns <em>true<\/em> if the server has closed the cursor. A closed cursor may still have documents remaining in the last received batch. Developers can use the <code><a href=\"https:\/\/docs.mongodb.com\/manual\/reference\/method\/cursor.isExhausted\/#cursor.isExhausted\" target=\"_blank\" rel=\"noopener\">cursor.isExhausted()<\/a><\/code> or the <code><a href=\"https:\/\/docs.mongodb.com\/manual\/reference\/method\/cursor.hasNext\/#cursor.hasNext\" target=\"_blank\" rel=\"noopener\">cursor.hasNext()<\/a><\/code> methods to check if the cursor is fully exhausted or not. Do <em>note<\/em>, the official documentation of this method doesn&#8217;t provide any query syntax for this method.<\/p>\n<h3>1.5 Code Snippet<\/h3>\n<p>Let&#8217;s understand the implementation of these methods with the help of a sample code snippet.<\/p>\n<pre class=\"brush:java;wrap-lines:false;\">var Db = require('mongodb').Db,\r\n    MongoClient = require('mongodb').MongoClient,\r\n    Server = require('mongodb').Server,\r\n    ReplSetServers = require('mongodb').ReplSetServers,\r\n    ObjectID = require('mongodb').ObjectID,\r\n    Binary = require('mongodb').Binary,\r\n    GridStore = require('mongodb').GridStore,\r\n    Grid = require('mongodb').Grid,\r\n    Code = require('mongodb').Code,\r\n    BSON = require('mongodb').pure().BSON;\r\n\r\n  \/\/ Set up the connection to the local db\r\n  var mongoclient = new MongoClient(new Server(\"home.mongolab.com\", 27017), {native_parser: true});\r\n\r\n  \/\/ Open the connection to the server\r\n  mongoclient.open(function(err, mongoclient) {\r\n\r\n    \/\/ Get the first db and do an update document on it\r\n    var db = mongoclient.db(\"warehouse\");\r\n    db.collection('editors').update({a:1}, {b:1}, {upsert:true}, function(err, result) {\r\n    \t\r\n      \/\/ Get another db and do an update document on it\r\n      var db2 = mongoclient.db(\"warehouse2\");\r\n      db2.collection('editors2').update({a:1}, {b:1}, {upsert:true}, function(err, result) {\r\n    \t  \r\n        \/\/ Close the connection\r\n        mongoclient.close();\r\n      });\r\n    });\r\n  });\r\n<\/pre>\n<p>That\u2019s all for this post. Happy Learning!!<\/p>\n<h2>2. Conclusion<\/h2>\n<p>In this tutorial, we learned about the <code>cursor.close()<\/code> and <code>cursor.isClosed()<\/code> methods of the Mongo database. Developers can download the sample commands in the <a href=\"#projectDownload\">Downloads<\/a> section.<\/p>\n<h2><a name=\"projectDownload\"><\/a>3. Download the Eclipse Project<\/h2>\n<p>This was an example of the <code>cursor.close()<\/code> and <code>cursor.isClosed()<\/code> methods available in the Mongo database.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/03\/Code-Snippet.zip\" target=\"_blank\" rel=\"noopener\"><strong>Code Snippet<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Hello readers, these days to increase the system capacity it is important to instruct the Mongo database to close a connection and free the associated database resources. In Mongo world, it is pretty straightforward and in this tutorial, we will see the cursor.close() and cursor.isClosed() methods available in the Mongo database. Let\u2019s study in brief &hellip;<\/p>\n","protected":false},"author":119,"featured_media":36154,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1447],"tags":[1194,1708],"class_list":["post-55885","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mongodb","tag-mongodb","tag-mongodb-cursor-methods"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>MongoDB close() and isClosed() Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Hello readers, in this tutorial, we will see the cursor.close() and cursor.isClosed() methods available in the Mongo database.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-close-isclosed-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MongoDB close() and isClosed() Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Hello readers, in this tutorial, we will see the cursor.close() and cursor.isClosed() methods available in the Mongo database.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-close-isclosed-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2018-03-05T13:00:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/04\/mongodb-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Yatin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Yatin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-close-isclosed-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-close-isclosed-example\/\"},\"author\":{\"name\":\"Yatin\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13\"},\"headline\":\"MongoDB close() and isClosed() Example\",\"datePublished\":\"2018-03-05T13:00:02+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-close-isclosed-example\/\"},\"wordCount\":718,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-close-isclosed-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/04\/mongodb-logo.jpg\",\"keywords\":[\"MongoDb\",\"MongoDB Cursor Methods\"],\"articleSection\":[\"MongoDB\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-close-isclosed-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-close-isclosed-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-close-isclosed-example\/\",\"name\":\"MongoDB close() and isClosed() Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-close-isclosed-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-close-isclosed-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/04\/mongodb-logo.jpg\",\"datePublished\":\"2018-03-05T13:00:02+00:00\",\"description\":\"Hello readers, in this tutorial, we will see the cursor.close() and cursor.isClosed() methods available in the Mongo database.\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-close-isclosed-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-close-isclosed-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-close-isclosed-example\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/04\/mongodb-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/04\/mongodb-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-close-isclosed-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Software Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/software-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"MongoDB\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/software-development\/mongodb\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"MongoDB close() and isClosed() Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13\",\"name\":\"Yatin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg\",\"caption\":\"Yatin\"},\"description\":\"An experience full-stack engineer well versed with Core Java, Spring\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).\",\"sameAs\":[\"https:\/\/www.javacodegeeks.com\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/yatin-batra\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"MongoDB close() and isClosed() Example - Java Code Geeks","description":"Hello readers, in this tutorial, we will see the cursor.close() and cursor.isClosed() methods available in the Mongo database.","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:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-close-isclosed-example\/","og_locale":"en_US","og_type":"article","og_title":"MongoDB close() and isClosed() Example - Java Code Geeks","og_description":"Hello readers, in this tutorial, we will see the cursor.close() and cursor.isClosed() methods available in the Mongo database.","og_url":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-close-isclosed-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2018-03-05T13:00:02+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/04\/mongodb-logo.jpg","type":"image\/jpeg"}],"author":"Yatin","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Yatin","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-close-isclosed-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-close-isclosed-example\/"},"author":{"name":"Yatin","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13"},"headline":"MongoDB close() and isClosed() Example","datePublished":"2018-03-05T13:00:02+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-close-isclosed-example\/"},"wordCount":718,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-close-isclosed-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/04\/mongodb-logo.jpg","keywords":["MongoDb","MongoDB Cursor Methods"],"articleSection":["MongoDB"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-close-isclosed-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-close-isclosed-example\/","url":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-close-isclosed-example\/","name":"MongoDB close() and isClosed() Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-close-isclosed-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-close-isclosed-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/04\/mongodb-logo.jpg","datePublished":"2018-03-05T13:00:02+00:00","description":"Hello readers, in this tutorial, we will see the cursor.close() and cursor.isClosed() methods available in the Mongo database.","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-close-isclosed-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-close-isclosed-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-close-isclosed-example\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/04\/mongodb-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/04\/mongodb-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-close-isclosed-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Software Development","item":"https:\/\/examples.javacodegeeks.com\/category\/software-development\/"},{"@type":"ListItem","position":3,"name":"MongoDB","item":"https:\/\/examples.javacodegeeks.com\/category\/software-development\/mongodb\/"},{"@type":"ListItem","position":4,"name":"MongoDB close() and isClosed() Example"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13","name":"Yatin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg","caption":"Yatin"},"description":"An experience full-stack engineer well versed with Core Java, Spring\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).","sameAs":["https:\/\/www.javacodegeeks.com"],"url":"https:\/\/examples.javacodegeeks.com\/author\/yatin-batra\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/55885","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/119"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=55885"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/55885\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/36154"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=55885"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=55885"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=55885"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}