Migrating to 1.7 - problems with SimpleDB

19 views
Skip to first unread message

SANDER SMITH

unread,
Jun 19, 2010, 2:33:42 PM6/19/10
to typ...@googlegroups.com
I'm in the process of migrating from Typica 1.6 to 1.7, and am having some trouble with some SimpleDB code. There are a few things I'm confused about.

What's the difference between com.xerox.amazonaws.sdb and com.xerox.amazonaws.simpledb? Which one should I be using?

I used to perform queries on my data by calling domain.listItems(query) and using the strange syntax that was enclosed in square brackets []. I see that all of those methods have been taken away. From what I can piece together, I think it is because Amazon is deprecating the whole Query functionality, right?

Okay, so now I assume that I must reimplement some of this code using the Select API. I'm having a little bit of trouble, and was hoping for some help.

The first thing I need to do is find out the number of records in a domain. I could call the metadata methods, but this is not good in my case because I need to know exactly how many records are there now, not 3 hours ago. I'm trying to select all of the records and count them, but I simply get an exception that says

  The specified query expression syntax is not valid.

What's wrong with the SELECT statement? Here's the code. I'm also not sure if I'm doing this right because the selectItems method is on the domain, but then I also need to pass the domain name in to the SELECT statement which doesn't seem right.

==========================
  public int getNumberRecords(String domainName)
    throws Exception
    {
    int numRecords = 0;
   
    Domain domain = simpleDB.getDomain(domainName);
     
    String nextToken = null;
    do
      { 
      String selectStatement = "SELECT * FROM " + domainName;       
   
      QueryWithAttributesResult queryResults = domain.selectItems(selectStatement,
                                                              nextToken);
      Map<String, List<ItemAttribute>> items = queryResults.getItems();
      numRecords+= items.size();
      nextToken = queryResults.getNextToken();
      }
    while (nextToken != null && !nextToken .trim().equals(""));     
 
    return numRecords;   
    }
==========================

SANDER SMITH

unread,
Jun 20, 2010, 1:33:21 PM6/20/10
to typ...@googlegroups.com
I've finally figured out he problem with my code. The statement

String selectStatement = "SELECT * FROM " + domainName;

is fine except when domainName has some funky characters in it. If so, then it must be "backticked" as is described here

http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1231&categoryID=152
 
 

--
You received this message because you are subscribed to the Google Groups "typica" group.
To post to this group, send email to typ...@googlegroups.com.
To unsubscribe from this group, send email to typica+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/typica?hl=en.

Reply all
Reply to author
Forward
0 new messages