|
Resources
Sample Code and Libraries
Small and Simple, SimpleDB Java Library [updated July 23, 2009]
 |
Very simple, easy to follow and modify Java code for SimpleDB. Does not depend on any third party libraries.
| Submitted By: |
ianschumacher
|
| AWS Products Used: |
Amazon SimpleDB |
| Language(s): |
Java |
| License: |
Apache License 2.0 |
|
|
 |
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}
{}
|
Posts:
7
Registered:
9/28/07
|
|
|
|
'Simple' SimpleDB code in single Java file/class (240 lines)
Posted:
Mar 29, 2008 3:54 AM PDT
|
|
|
Interesting, do you have any use cases, thanks in advance,
|
|
Posts:
20
Registered:
2/8/06
|
|
|
|
Re: 'Simple' SimpleDB code in single Java file/class (240 lines)
Posted:
Jun 26, 2008 2:08 AM PDT
in response to: Macro books
|
|
|
This is a great class, and illustrates the power that Amazon can offer and how you can really utilise this power without over complicating the problem.
I love the simplicity of this class and I applaud the author for illustrating how easy it is to use.
I have since added to this class, with some helper methods you can access here:
http://alan.blog-city.com/simpleclass_amazondb.htm
|
|
Posts:
20
Registered:
2/8/06
|
|
|
|
Re: 'Simple' SimpleDB code in single Java file/class (240 lines)
Posted:
Oct 7, 2008 4:21 AM PDT
in response to: A. R. Williamson
|
|
|
Carrying on the tradition of this wonderfully simple class, i have made some further updates to include more of the SimpleDB API.
It includes a very simple in-class XML parser that will convert the strings into something useful. Does not use SAX or DOM.
In the same spirit, this class requires no external dependencies or even an XML parser!
http://alan.blog-city.com/simpleclass_amazondb_oct2008.htm
|
|
|
|
 |
|
|