{"id":46584,"date":"2019-01-10T00:00:00","date_gmt":"2019-01-10T08:00:00","guid":{"rendered":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/blog\/your-first-griddb-java-application\/"},"modified":"2025-11-13T12:54:44","modified_gmt":"2025-11-13T20:54:44","slug":"your-first-griddb-java-application","status":"publish","type":"post","link":"https:\/\/www.griddb.net\/en\/blog\/your-first-griddb-java-application\/","title":{"rendered":"Your First GridDB Java Application."},"content":{"rendered":"<p>If you prefer videos: <\/p>\n<div style=\"text-align: center; padding: 25px\">\n<iframe width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/TMQAZrRHFuE\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<\/div>\n<p>You&#8217;ve got GridDB installed using the <a href=\"https:\/\/griddb.net\/en\/blog\/griddb-quickstart\/\">Quickstart blogpost<\/a> and now it&#8217;s time to start developing your first Java application. This blog post will take you through the basics:<br \/>\nFirst, the required import statements:<\/p>\n<pre>\nimport com.toshiba.mwcloud.gs.Collection;\nimport com.toshiba.mwcloud.gs.GSException;\nimport com.toshiba.mwcloud.gs.GridStore;\nimport com.toshiba.mwcloud.gs.GridStoreFactory;\nimport com.toshiba.mwcloud.gs.Query;\nimport com.toshiba.mwcloud.gs.RowKey;\nimport com.toshiba.mwcloud.gs.RowSet;\n<\/pre>\n<p>The container schema is defined as a static Class in Java.<\/p>\n<pre>\nstatic class Person {\n\t@RowKey String name;\n\tint age;\n}\nstatic class HeartRate {\n\t@RowKey Date ts;\n\tint heartRate;\n        String activity;\n}\n<\/pre>\n<p>To connect to GridDB, you create a Properties instance with the particulars of your GridDB installation.<\/p>\n<pre>\nProperties props = new Properties();\nprops.setProperty(\"notificationAddress\", \"239.0.0.1\");\nprops.setProperty(\"notificationPort\", \"31999\");\nprops.setProperty(\"clusterName\", \"defaultCluster\");\nprops.setProperty(\"user\", \"admin\");\nprops.setProperty(\"password\", \"admin\");\nGridStore store = GridStoreFactory.getInstance().getGridStore(props);\n<\/pre>\n<p>To perform queries or write records, you first need to get the container:<\/p>\n<pre>\nCollection&lt;String, Person&gt; people = store.putCollection(\"PEOPLE\", Person.class);\n<\/pre>\n<p>Querying is similar to SQL\/JDBC drivers.<\/p>\n<pre>\nQuery&lt;Person&lt; query = col.query(\"select * where name = 'John'\");\nRowSet&lt;Person&gt; rs = query.fetch(false);\nwhile (rs.hasNext()) {\n\t\/\/ Update the searched Row\n\tPerson person1 = rs.next();\n        System.out.println(\"Name: \"+ person1.name +\" Age: \"+ person1.age)\n}\n<\/pre>\n<p>Writing is simple&#8230;<\/p>\n<pre>\nHeartRate hr = new HeartRate();\nhr.ts = new Date();\nhr.heartrate = 60;\nhr.activity = \"resting\";\nTimeSeries&lt;HeartRate&gt; heartRate = store.putTimeSeries(\"HR_\"+person1.name, HeartRate.class);\nheartRate.put(hr);\n<\/pre>\n<p>Updating is simple:<\/p>\n<pre>\nQuery&lt;Person&gt; query = col.query(\"select * where name = 'John'\");\nRowSet&lt;Person&gt; rs = query.fetch(true);\nwhile (rs.hasNext()) {\n\t\/\/ Update the searched Row\n\tPerson person1 = rs.next();\n        person1.age++;\n        rs.update(person1);\n}\n<\/pre>\n<p>To compile use the following snippet.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">\n$ cd gsSample\/\n$ export CLASSPATH=$CLASSPATH:\/usr\/share\/java\/gridstore.jar\n$ javac Sample1.java\n$ cd .. && java gsSample\/Sample1\n<\/code>\n<\/pre>\n<\/div>\n<p>Alternatively, you can check out how to use maven with GridDB <a href=\"https:\/\/griddb.net\/en\/blog\/using-maven-to-develop-griddb-applications\/\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you prefer videos: You&#8217;ve got GridDB installed using the Quickstart blogpost and now it&#8217;s time to start developing your first Java application. This blog post will take you through the basics: First, the required import statements: import com.toshiba.mwcloud.gs.Collection; import com.toshiba.mwcloud.gs.GSException; import com.toshiba.mwcloud.gs.GridStore; import com.toshiba.mwcloud.gs.GridStoreFactory; import com.toshiba.mwcloud.gs.Query; import com.toshiba.mwcloud.gs.RowKey; import com.toshiba.mwcloud.gs.RowSet; The container schema is [&hellip;]<\/p>\n","protected":false},"author":71,"featured_media":25786,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[121],"tags":[],"class_list":["post-46584","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Your First GridDB Java Application. | GridDB: Open Source Time Series Database for IoT<\/title>\n<meta name=\"description\" content=\"If you prefer videos: You&#039;ve got GridDB installed using the Quickstart blogpost and now it&#039;s time to start developing your first Java application. This\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/griddb.net\/en\/blog\/your-first-griddb-java-application\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Your First GridDB Java Application. | GridDB: Open Source Time Series Database for IoT\" \/>\n<meta property=\"og:description\" content=\"If you prefer videos: You&#039;ve got GridDB installed using the Quickstart blogpost and now it&#039;s time to start developing your first Java application. This\" \/>\n<meta property=\"og:url\" content=\"https:\/\/griddb.net\/en\/blog\/your-first-griddb-java-application\/\" \/>\n<meta property=\"og:site_name\" content=\"GridDB: Open Source Time Series Database for IoT\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/griddbcommunity\/\" \/>\n<meta property=\"article:published_time\" content=\"2019-01-10T08:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-11-13T20:54:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.griddb.net\/wp-content\/uploads\/2019\/01\/blog_title_31.png\" \/>\n\t<meta property=\"og:image:width\" content=\"870\" \/>\n\t<meta property=\"og:image:height\" content=\"490\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Owen\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@GridDBCommunity\" \/>\n<meta name=\"twitter:site\" content=\"@GridDBCommunity\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Owen\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/griddb.net\/en\/blog\/your-first-griddb-java-application\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/your-first-griddb-java-application\/\"},\"author\":{\"name\":\"Owen\",\"@id\":\"https:\/\/griddb.net\/en\/#\/schema\/person\/0f2f6d4b593adde8c43cf3ea5c794c66\"},\"headline\":\"Your First GridDB Java Application.\",\"datePublished\":\"2019-01-10T08:00:00+00:00\",\"dateModified\":\"2025-11-13T20:54:44+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/your-first-griddb-java-application\/\"},\"wordCount\":115,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/griddb.net\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/your-first-griddb-java-application\/#primaryimage\"},\"thumbnailUrl\":\"\/wp-content\/uploads\/2019\/01\/blog_title_31.png\",\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/griddb.net\/en\/blog\/your-first-griddb-java-application\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/griddb.net\/en\/blog\/your-first-griddb-java-application\/\",\"url\":\"https:\/\/griddb.net\/en\/blog\/your-first-griddb-java-application\/\",\"name\":\"Your First GridDB Java Application. | GridDB: Open Source Time Series Database for IoT\",\"isPartOf\":{\"@id\":\"https:\/\/griddb.net\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/your-first-griddb-java-application\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/your-first-griddb-java-application\/#primaryimage\"},\"thumbnailUrl\":\"\/wp-content\/uploads\/2019\/01\/blog_title_31.png\",\"datePublished\":\"2019-01-10T08:00:00+00:00\",\"dateModified\":\"2025-11-13T20:54:44+00:00\",\"description\":\"If you prefer videos: You've got GridDB installed using the Quickstart blogpost and now it's time to start developing your first Java application. This\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/griddb.net\/en\/blog\/your-first-griddb-java-application\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/griddb.net\/en\/blog\/your-first-griddb-java-application\/#primaryimage\",\"url\":\"\/wp-content\/uploads\/2019\/01\/blog_title_31.png\",\"contentUrl\":\"\/wp-content\/uploads\/2019\/01\/blog_title_31.png\",\"width\":870,\"height\":490},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/griddb.net\/en\/#website\",\"url\":\"https:\/\/griddb.net\/en\/\",\"name\":\"GridDB: Open Source Time Series Database for IoT\",\"description\":\"GridDB is an open source time-series database with the performance of NoSQL and convenience of SQL\",\"publisher\":{\"@id\":\"https:\/\/griddb.net\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/griddb.net\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/griddb.net\/en\/#organization\",\"name\":\"Fixstars\",\"url\":\"https:\/\/griddb.net\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/griddb.net\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png\",\"contentUrl\":\"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png\",\"width\":200,\"height\":83,\"caption\":\"Fixstars\"},\"image\":{\"@id\":\"https:\/\/griddb.net\/en\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/griddbcommunity\/\",\"https:\/\/x.com\/GridDBCommunity\",\"https:\/\/www.linkedin.com\/company\/griddb-by-toshiba\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/griddb.net\/en\/#\/schema\/person\/0f2f6d4b593adde8c43cf3ea5c794c66\",\"name\":\"Owen\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/griddb.net\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/47438a5c81215c7a9043be1b427e0bbd8dc0f77bd536f147f8495575149e4325?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/47438a5c81215c7a9043be1b427e0bbd8dc0f77bd536f147f8495575149e4325?s=96&d=mm&r=g\",\"caption\":\"Owen\"},\"url\":\"https:\/\/www.griddb.net\/en\/author\/owen\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Your First GridDB Java Application. | GridDB: Open Source Time Series Database for IoT","description":"If you prefer videos: You've got GridDB installed using the Quickstart blogpost and now it's time to start developing your first Java application. This","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:\/\/griddb.net\/en\/blog\/your-first-griddb-java-application\/","og_locale":"en_US","og_type":"article","og_title":"Your First GridDB Java Application. | GridDB: Open Source Time Series Database for IoT","og_description":"If you prefer videos: You've got GridDB installed using the Quickstart blogpost and now it's time to start developing your first Java application. This","og_url":"https:\/\/griddb.net\/en\/blog\/your-first-griddb-java-application\/","og_site_name":"GridDB: Open Source Time Series Database for IoT","article_publisher":"https:\/\/www.facebook.com\/griddbcommunity\/","article_published_time":"2019-01-10T08:00:00+00:00","article_modified_time":"2025-11-13T20:54:44+00:00","og_image":[{"width":870,"height":490,"url":"https:\/\/www.griddb.net\/wp-content\/uploads\/2019\/01\/blog_title_31.png","type":"image\/png"}],"author":"Owen","twitter_card":"summary_large_image","twitter_creator":"@GridDBCommunity","twitter_site":"@GridDBCommunity","twitter_misc":{"Written by":"Owen","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/griddb.net\/en\/blog\/your-first-griddb-java-application\/#article","isPartOf":{"@id":"https:\/\/griddb.net\/en\/blog\/your-first-griddb-java-application\/"},"author":{"name":"Owen","@id":"https:\/\/griddb.net\/en\/#\/schema\/person\/0f2f6d4b593adde8c43cf3ea5c794c66"},"headline":"Your First GridDB Java Application.","datePublished":"2019-01-10T08:00:00+00:00","dateModified":"2025-11-13T20:54:44+00:00","mainEntityOfPage":{"@id":"https:\/\/griddb.net\/en\/blog\/your-first-griddb-java-application\/"},"wordCount":115,"commentCount":0,"publisher":{"@id":"https:\/\/griddb.net\/en\/#organization"},"image":{"@id":"https:\/\/griddb.net\/en\/blog\/your-first-griddb-java-application\/#primaryimage"},"thumbnailUrl":"\/wp-content\/uploads\/2019\/01\/blog_title_31.png","articleSection":["Blog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/griddb.net\/en\/blog\/your-first-griddb-java-application\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/griddb.net\/en\/blog\/your-first-griddb-java-application\/","url":"https:\/\/griddb.net\/en\/blog\/your-first-griddb-java-application\/","name":"Your First GridDB Java Application. | GridDB: Open Source Time Series Database for IoT","isPartOf":{"@id":"https:\/\/griddb.net\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/griddb.net\/en\/blog\/your-first-griddb-java-application\/#primaryimage"},"image":{"@id":"https:\/\/griddb.net\/en\/blog\/your-first-griddb-java-application\/#primaryimage"},"thumbnailUrl":"\/wp-content\/uploads\/2019\/01\/blog_title_31.png","datePublished":"2019-01-10T08:00:00+00:00","dateModified":"2025-11-13T20:54:44+00:00","description":"If you prefer videos: You've got GridDB installed using the Quickstart blogpost and now it's time to start developing your first Java application. This","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/griddb.net\/en\/blog\/your-first-griddb-java-application\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/griddb.net\/en\/blog\/your-first-griddb-java-application\/#primaryimage","url":"\/wp-content\/uploads\/2019\/01\/blog_title_31.png","contentUrl":"\/wp-content\/uploads\/2019\/01\/blog_title_31.png","width":870,"height":490},{"@type":"WebSite","@id":"https:\/\/griddb.net\/en\/#website","url":"https:\/\/griddb.net\/en\/","name":"GridDB: Open Source Time Series Database for IoT","description":"GridDB is an open source time-series database with the performance of NoSQL and convenience of SQL","publisher":{"@id":"https:\/\/griddb.net\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/griddb.net\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/griddb.net\/en\/#organization","name":"Fixstars","url":"https:\/\/griddb.net\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/griddb.net\/en\/#\/schema\/logo\/image\/","url":"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png","contentUrl":"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png","width":200,"height":83,"caption":"Fixstars"},"image":{"@id":"https:\/\/griddb.net\/en\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/griddbcommunity\/","https:\/\/x.com\/GridDBCommunity","https:\/\/www.linkedin.com\/company\/griddb-by-toshiba"]},{"@type":"Person","@id":"https:\/\/griddb.net\/en\/#\/schema\/person\/0f2f6d4b593adde8c43cf3ea5c794c66","name":"Owen","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/griddb.net\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/47438a5c81215c7a9043be1b427e0bbd8dc0f77bd536f147f8495575149e4325?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/47438a5c81215c7a9043be1b427e0bbd8dc0f77bd536f147f8495575149e4325?s=96&d=mm&r=g","caption":"Owen"},"url":"https:\/\/www.griddb.net\/en\/author\/owen\/"}]}},"_links":{"self":[{"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/posts\/46584","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/users\/71"}],"replies":[{"embeddable":true,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/comments?post=46584"}],"version-history":[{"count":1,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/posts\/46584\/revisions"}],"predecessor-version":[{"id":51271,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/posts\/46584\/revisions\/51271"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/media\/25786"}],"wp:attachment":[{"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/media?parent=46584"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/categories?post=46584"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/tags?post=46584"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}