Preparing the Samples

To complete the following sections, you must make configuration changes to the sample files.

Java

To prepare the sample files

  1. Extract the Amazon SimpleDB sample code into a directory on your machine designated as <sdb home>.

  2. Configure your CLASSPATH environment variable to point to the Amazon SimpleDB Samples JAR archive and the included third party JARs. The following is an example in Linux.

    export CLASSPATH=$CLASSPATH:\
    <sdb home>/amazon-simpledb-2007-11-07-java-library\
    /src/com/amazonaws/sdb/samples/\
    <sdb home>/lib/amazon-simpledb-2007-11-07-java-library.jar:\
    <sdb home>/third-party/jakarta-commons/commons-codec-1.3.jar:\
    <sdb home>/third-party/jakarta-commons/commons-httpclient-3.0.1.jar:\
    <sdb home>/third-party/jakarta-commons/commons-logging-1.1.jar:\
    <sdb home>/third-party/jaxb-ri-2.1/activation.jar:\
    <sdb home>/third-party/jaxb-ri-2.1/jaxb-all-deps.jar:\
    <sdb home>/third-party/jaxb-ri-2.1/jaxb-api.jar:\
    <sdb home>/third-party/jaxb-ri-2.1/jaxb-impl.jar:\
    <sdb home>/third-party/jaxb-ri-2.1/jaxb-xjc.jar:\
    <sdb home>/third-party/jaxb-ri-2.1/jsr173_1.0_api.jar:\
    <sdb home>/third-party/log4j/log4j-1.2.14.jar
    
    
  3. The following command changes your working directory.

    <sdb home>/amazon-simpledb-2007-11-07-java-library/src/com/amazonaws/sdb/samples/
  4. Open src/com/amazonaws/sdb/samples/CreateDomainSample.java.

  5. Determine whether you will run the code against the mock service or your Amazon SimpleDB account:

    • To run the code against the mock service, comment out the following lines:

      String accessKeyId = "<Your Access Key ID>";
      String secretAccessKey = "<Your Secret Access Key>"
      AmazonSimpleDB service  = new AmazonSimpleDBClient(accessKeyId, secretAccessKey)
      

      Then, remove comment marks from the following line:

      AmazonSimpleDB service = new AmazonSimpleDBMock();
      
    • To run the code against Amazon SimpleDB, make sure the following lines are not commented out and enter your Access Key ID and Secret Access Key:

      String accessKeyId = "<Your Access Key ID>";
      String secretAccessKey = "<Your Secret Access Key>"
      AmazonSimpleDB service  = new AmazonSimpleDBClient(accessKeyId, secretAccessKey)
      

      Make sure the following line is commented out:

      AmazonSimpleDB service = new AmazonSimpleDBMock();
      
  6. Save the file.

  7. Repeat this procedure for each file in the samples directory.

C#

Note that the C# example performs all actions in one call: creating a domain, listing a domain, putting data into a domain, getting data from a domain, deleting values from an attribute, deleting an attribute, replacing an attribute, deleting an item, and deleting a domain.

To prepare the sample files

  1. Go to the AWS SDK for .NET page and download the AWS .NET SDK.

  2. Run the downloaded installation program, AWSSDKInstaller.msi.

    The installation installs to C:\Program Files\AWS SDK for .NET by default.

  3. Go to C:\Program Files\AWS SDK for .NET\samples and unzip the AmazonSimpleDB_Sample.zip to a directory on your machine designated as <sdb home>.

  4. Open the following sample solution: <sdb home>/AmazonSimpleDB_Sample/AmazonSimpleDB_Sample.sln.

  5. Open the App.config file.

  6. Enter your Access Key ID and Secret Access Key:

    <add key="AWSAccessKey" value="<Your Access Key ID>"/>
    <add key="AWSSecretKey" value="<Your Secret Access Key>"/>
  7. Save the file.

Perl

To prepare the sample files

  1. Extract the Amazon SimpleDB sample code into a directory on your machine designated as <sdb home>.

  2. Open the src/Amazon/SimpleDB/Samples/CreateDomainSample.pl sample file.

  3. Determine whether you will run the code against the mock service or your Amazon SimpleDB account:

    • To run the code against the mock service, comment out the following lines:

      my $AWS_ACCESS_KEY_ID        = "<Your Access Key ID>";
       my $AWS_SECRET_ACCESS_KEY    = "<Your Secret Access Key>";
      use Amazon::SimpleDB::Client;
      my $service = Amazon::SimpleDB::Client->new($AWS_ACCESS_KEY_ID, $AWS_SECRET_ACCESS_KEY);
      

      Then, remove comment marks from the following line:

      use Amazon::SimpleDB::Mock;
      my $service = Amazon::SimpleDB::Mock->new;
      
    • To run the code against Amazon SimpleDB, make sure the following lines are not commented out and enter your Access Key ID and Secret Access Key:

      my $AWS_ACCESS_KEY_ID        = "<Your Access Key ID>";
       my $AWS_SECRET_ACCESS_KEY    = "<Your Secret Access Key>";
      use Amazon::SimpleDB::Client;
      my $service = Amazon::SimpleDB::Client->new($AWS_ACCESS_KEY_ID, $AWS_SECRET_ACCESS_KEY);
      

      Make sure the following lines are commented out:

      use Amazon::SimpleDB::Mock;
      my $service = Amazon::SimpleDB::Mock->new;
      
  4. Save the file.

  5. Repeat this procedure for each file in the samples directory.

PHP

To prepare the sample files

  1. Extract the Amazon SimpleDB sample code into a directory on your machine designated as <sdb home>.

  2. Open a sample file in the src/Amazon/SimpleDB/Samples/ directory.

  3. Determine whether you will run the code against the mock service or your Amazon SimpleDB account:

    • To run the code against the mock service, comment out the following lines:

      $AWS_ACCESS_KEY_ID        = 'Your Access Key ID';
      $AWS_SECRET_ACCESS_KEY    = 'Your Secret Access Key';
      require_once ('Amazon/SimpleDB/Client.php');
      $service = new Amazon_SimpleDB_Client($AWS_ACCESS_KEY_ID, $AWS_SECRET_ACCESS_KEY;
      

      Then, remove comment marks from the following line:

      require_once ('Amazon/SimpleDB/Mock.php');
      $service = new Amazon_SimpleDB_Mock();
      
    • To run the code against Amazon SimpleDB, make sure the following lines are not commented out and enter your Access Key ID and Secret Access Key:

      $AWS_ACCESS_KEY_ID        = 'Your Access Key ID';
      $AWS_SECRET_ACCESS_KEY    = 'Your Secret Access Key';
      require_once ('Amazon/SimpleDB/Client.php');
      $service = new Amazon_SimpleDB_Client($AWS_ACCESS_KEY_ID, $AWS_SECRET_ACCESS_KEY;
      

      Make sure the following lines are commented out:

      require_once ('Amazon/SimpleDB/Mock.php');
      $service = new Amazon_SimpleDB_Mock();
      
  4. Save the file.

  5. Repeat this procedure for each file in the samples directory.

Scratchpad

The scratchpad is a sample web application that enables you to test and make calls to Amazon SimpleDB without having to set up a programming environment.

To prepare the scratchpad

  1. Copy the scratchpad files to a location on your computer.

  2. Open the index.html file with a web browser. The welcome page appears.

  3. Enter your AWS Access Key ID and your Secret Access Key.

  4. Follow the tutorial described in the remainder of this document.