On Amazon simpleDB and pagination again!

I finally got my google-style pagination working with JSP and Java servlets. Damn the select count(*) is interesting in SimpleDB. you gotta do something like:

SelectRequest request = new SelectRequest();

String select_Expression = "select count(*) from dllcloud";

request.withSelectExpression(select_Expression);

try {
service = new AmazonSimpleDBClient(accessKeyId, secretAccessKey);

SelectResponse response = service.select(request);

SelectResult result = response.getSelectResult();

List all_items = result.getItem();

for (Item item : all_items) {
List attributeList = item.getAttribute();

for (Attribute attribute : attributeList) {
if (attribute.isSetName()) {
if (attribute.getName().equalsIgnoreCase("Count")) {
if (attribute.isSetValue()) {
total_records = Integer.parseInt(attribute.getValue());
setTotal_records(total_records);
}
}
}
}
}
} catch (Exception e) {
}

Well I guess someone might have discovered a different solution BUT it turns out that select count(*) in SimpleDB returns

itemName() = "Domain",
attributeName() = "Count" and
attributeValue() = "number of items in the domain queried"
.

Any funky suggestions are welcome and would be greatly appreciated.

Comments

Popular posts from this blog

Honolulu, HI, United States!

Death strikes yet again!

A Holiday in the Hawaiian Islands!