Small and Simple, SimpleDB Java Library [updated July 23, 2009]

Sample Code & Libraries>Small and Simple, SimpleDB Java Library [updated July 23, 2009]
Community Contributed Software

  • Amazon Web Services provides links to these packages as a convenience for our customers, but software not authored by an "@AWS" account has not been reviewed or screened by AWS.
  • Please review this software to ensure it meets your needs before using it.

Very simple, easy to follow and modify Java code for SimpleDB. Does not depend on any third party libraries.

Details

Submitted By: ianschumacher
AWS Products Used: Amazon SimpleDB
Language(s): Java
License: Apache License 2.0
Created On: February 20, 2008 10:24 PM GMT
Last Updated: July 26, 2009 1:29 AM GMT
Download
Earlier I had written a very small single Java file for accessing and querying SimpleDB. This is an update to that. This version updates the signing mechanism to latest spec, parses and processes the XML. The code assumes a single value per key model, which allows it to use standard maps to represent tuples and tables, simplifying usage.

Example:

SDB sdb = new SDB("YOUR KEY HERE", "YOUR SECRET HERE");
sdb.createDomain("test");
System.out.println(Arr.toString(sdb.listDomains()));
TreeMap map = new TreeMap();
map.put("id", "item1");
map.put("a", "av");
map.put("b", "bv");
sdb.putAttributes("test", map);
System.out.println(sdb.getAttributes("test", "item1"));
System.out.println(Arr.toString(sdb.select("select * from test")));
map = new TreeMap();
map.put("id", "item1");
sdb.deleteAttributes("test", map);
System.out.println(sdb.getAttributes("test", "item1"));
sdb.deleteDomain("test");
System.out.println(Arr.toString(sdb.listDomains()));


This results in the output:
{test}
{a=av, b=bv, id=item1}
{{a=av, b=bv, id=item1}}
{id=item1}
{}
©2014, Amazon Web Services, Inc. or its affiliates. All rights reserved.