2011-12-18 60 views
2

我使用這些代碼來連接SimpleDB和查詢數據。 我可以在SQL Scrap Book中運行查詢,結果是OK。 但是當我在Eclipse中運行它,我得到錯誤信息:關於Amazon SimpleDB,選擇功能

"12-18 22:01:57.401: I/com.amazonaws.request(402): Received error response: Status Code: 400, AWS Request ID: d68b7fcc-cd4a-7def-602c-96ad189d8fcf, AWS Error Code: NoSuchDomain, AWS Error Message: The specified domain does not exist." 

你有任何想法?

//1. Creating a SimpleDB Client 
AWSCredentials credentials = new BasicAWSCredentials(ACCESS_KEY_ID, SECRET_KEY); 
AmazonSimpleDBClient sdbClient = new AmazonSimpleDBClient(credentials);   

//2. Select 
String nextToken = null; 
SelectRequest selectRequest = new SelectRequest("select * from mydomain").withConsistentRead(true); 
selectRequest.setNextToken(nextToken);   
SelectResult response = sdbClient.select(selectRequest); 
nextToken = response.getNextToken(); 

回答

2

您需要在爲域請求數據之前指定服務器區域終點。 Amazon Simple DB支持7個區域端點。

地區,端點

"US-East(Northern Virginia)", "sdb.amazonaws.com" 
"EU(Ireland)", "sdb.eu-west-1.amazonaws.com" 
"US-West(Northern California)", "sdb.us-west-1.amazonaws.com" 
"Asia Pacific(Singapore)", "sdb.ap-southeast-1.amazonaws.com" 
"Asia Pacific(Tokyo)", "sdb.ap-northeast-1.amazonaws.com" 
"US West(Oregon)", "sdb.us-west-2.amazonaws.com" 
"South America(Sao Paulo)", "sdb.sa-east-1.amazonaws.com" 

如何設置區域終點

BasicAWSCredentials basicAWSCredentials = new BasicAWSCredentials(sAccessKey, sSecretKey); 
AmazonSimpleDBClient amazonSimpleDBClient = new AmazonSimpleDBClient(basicAWSCredentials); 
amazonSimpleDBClient.setEndpoint(Endpoint); 
0

感謝的人!我只是自己想清楚了。 Here's whole code:

//1. Creating a SimpleDB Client 
AWSCredentials credentials = new BasicAWSCredentials(ACCESS_KEY, SECRET_KEY); 
AmazonSimpleDBClient sdbClient = new AmazonSimpleDBClient(credentials); 
sdbClient.setEndpoint("sdb.us-west-1.amazonaws.com"); // to define Data Center Region 

//2. Select 
String nextToken = null; 
SelectRequest selectRequest = new SelectRequest("select * from myDomain").withConsistentRead(true); 
selectRequest.setNextToken(nextToken);   
SelectResult response = sdbClient.select(selectRequest); 
nextToken = response.getNextToken();