top of page

Inserting data into DynamoDB by using Java

Let's insert some data into DynamoDB by using Java.



2. Sample data to insert, it is separated with comma ',' for each column.



973,16.892068,96.220533,Phone Gyi Lan,ဘုန်းကြီးလမ်း,Kyansitthar Road,ကျန်စစ်သားလမ်း,East Dagon,အရှေ့ဒဂုံ


3. Create Map<String, Object> dataMap object with above sample data.



Map<String, Object> dataMap = new HashMap<String, Object>();
dataMap.put("id", "973");
dataMap.put("lat", "16.892068");
dataMap.put("lng", "96.220533");
dataMap.put("name_en", "Phone Gyi Lan");
dataMap.put("name_mm", "ဘုန်းကြီးလမ်း");
dataMap.put("road_en", "Kyansitthar Road");
dataMap.put("road_mm", "ကျန်စစ်သားလမ်း");
dataMap.put("twsp_en", "East Dagon");
dataMap.put("twsp_mm", "အရှေ့ဒဂုံ");


4. Please read https://jonathanphyo.wixsite.com/techbook/post/dynamodb-setup-with-java-sdk-spring-boot to setup DynamoDB SDK and to open connection to local dynamoDB.


Example:


5. Call the following insert() method.

Please note that it won't insert if one of the value is "null" or empty string.


As the result in DynamoDB, (http://localhost:8000/shell/)


Enjoy!


Comments


Single post: Blog_Single_Post_Widget
bottom of page