alanwilliamson

A simple Java API class for Amazon SimpleDB

We recently had cause to utilise the latest addition to Amazon's Web Services platform, SimpleDB. There are a number of Java libraries to get up and running with, and each one has their strengths and weaknesses.

When I coded up the SimpleDB for inclusion into OpenBD, I used the typica library, which is a great set of API's. Although recently, for another project, I just wanted something real quick, and while typica is nice, it does have some funky JAR file dependencies that makes it non trivial to install at times.

simple life

I found this chap, which is a single class that does everything inside one class and does not require any external JAR files that are not within the JDK.

Not a single XML parser in sight. It merely packages up the REST call to Amazon, doing all the authenication token passing, and then dumps you the resulting response back. Nice and simple.

And it works beautifully!

I decided to add to it though, with a very crude parsing algorithm (no SAX/DOM parser) to pull out the results from the XML packet and put them into something the calling function can use. Amazon's XML is so simple you don't need the extra overhead of those fully rounded parsers in 99% of the time.

So instead of calling listDomains(), which returns the raw string, you can now call listDomainsList() that will return a java.util.List of domains. I've added the same for the other methods where you need the actual data back out from the web service call.

Thanks to Ian Schumacher for developing the original class and making it available on Amazon under a very liberal license (Absolutely free in all senses of the word, absolutely no restrictions, no attribution necessary).

In the same spirit, I include the modified version of that code here, to be used in the same spirit as the original author. Just Use It!

Adapated from the original code submission.

Comments

Thank you for the kind words and I love your enhancement of the code.

left by Ian Schumacher — Thursday, 17 July 2008 2:07 PM

Have you tried calling it a number of times. It will be limited by the size of the URL in a single GET. So you may be hitting against that.

Remember also, a single element can only be 1K, thats an Amazon limitation, not a Java class one.

left by Alan Williamson — Friday, 4 July 2008 10:14 AM — web site

HI ,

I have question regarding the simpledb upload program, in Java. The program is itself gr8 and runs gr8. Is ther anything wrong with putAttribute function, i mean r this its limitations.

But when i try to write data with more than 10 attr to a single domain, it fails. It works fine with ruby but i need it in java. It also works fine when attributes are less then 10. Can you tell am I going wrong. some where or its the limitation of the method we are using.

Karan Cal State University, Fullerton

left by Karan — Thursday, 3 July 2008 9:19 PM

Leave Comment

please note, all comments will be moderated for spam and abuse before being publicly posted.


 

Recent Cloud posts

Recent JAVA posts

Latest CFML posts


 
Site Links
Recommended Sites/Blogs