AmazonSimpleDB sdb = new AmazonSimpleDBClient(new AWSCredentials() { @Override public String getAWSSecretKey() { return "********************"; } @Override public String getAWSAccessKeyId() { return "********************"; } }); String sql = new StringBuilder("SELECT * FROM ") .append("hoge") .append( " WHERE itemName() is not null AND startDate is not null") .append(" AND startDate >= '") .append(SimpleDBUtils.encodeDate(new Date())) .append("' ") .append(" ORDER BY startDate asc limit 10") .toString(); SelectResult select = sdb.select(new SelectRequest(sql).withConsistentRead(true)); List<Item> items = select.getItems(); for (Item item : items) { List<Attribute> attributes = item.getAttributes(); for (Attribute attr : attributes) { String name = attr.getName(); String value = attr.getValue(); } }
注意点はwhere句,order句に使うカラムはあらかじめnullチェックをSQLに混ぜ込む必要があります。 日付形式はSimpleDBUtils.encodeDateを使ってよろしくフォーマットします。