<?php require_once( dirname(dirname(dirname( __FILE__ ))) . '/wp-load.php' ); ?>
<!-- START of header -->
<?php get_header(); ?>
<!-- END of header -->

<!-- warapper -->

<div class="docs-content">
<!-- START of page navigation -->
<?php get_template_part( 'docs_navigation' ); ?>
<!-- END of page navigation -->
<!-- START of pusher -->
<div class="docs-content-body">
<div id="content" class="docs-content-body__inner">

<h1 class="title">5.1.9 Data Retrieval</h1>
<h2 id="overview">Overview</h2>
<p>This chapter covers retrieving data using the GridDB API.</p>
<p><br/></p>
<h2 id="data-acquisition">Retrieve data</h2>
<p>Retrieve data in a collection with specifying a Row key.</p>
<strong> List.1 Data Read</strong> (WeatherStationLogic.java)
<pre class="prettyprint linenums:23">
// Get Collection
Collection <String, WeatherStation> weatherStationCol =
        store.getCollection("weather_station", WeatherStation.class);
}
</pre>
<ul>
<li>L.24-25: Retrieve a collection by specifying a container name</li>
</ul>
<p><strong>List.2 Data Read by Row Key</strong>(CollectionRetrieve.java)</p>
<pre class="prettyprint linenums:27">
try {
    System.out.println("ID \tName \t \t \tLongitude \tLatitude \tCamera");
    for (int i=0; i &lt; WeatherStationLogic.JP_PREFECTURE; i ++) {
        // Retrieve row by key
        WeatherStation weatherStation=weatherStationCol.get (String.valueOf (i + 1));
        System.out.println (String.format("% - 3s \t% -20s \t% -10s \t% -10s \t% -5s",
        weatherStation.id, weatherStation.name, weatherStation.latitude,
        weatherStation.longitude, weatherStation.hasCamera));
    }
} Finally {
    // Close Connection
    weatherStationCol.close ();
}
</pre>
<ul>
<li>L.31: Retrieve a Row with specifying the measuring instrument ID of the key.</li>
</ul>
<p><br/> Execution results are as follows.</p>
<strong> List.3 Result </strong>
<pre class="prettyprint">
ID  Name            Longitude   Latitude    Camera
1   Hokkaido-Sapporo    43.06417    141.34694   true
2   Aomori-Aomori       40.82444    140.74      false
3   Iwate-Morioka       39.70361    141.1525    true
4   Miyagi-Sendai       38.26889    140.87194   false
5   Akita-Akita     39.71861    140.1025    true
(Snip)
</pre>
<p><br/></p>
<h2 id="complete-source-code">Complete source code</h2>
<p>Complete source code used in this sample can be downloaded from the following.</p>
<p>Download: <a href="img/collection-retrieve.zip">collection-retrieve.zip</a></p>
</div>
</div>
</div>
</div>
</div>
<!-- / main -->

<?php get_footer(); ?>
