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#

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 following sample solution: <sdb home>/amazon-simpledb-2007-11-07-cs-library/src/Amazon.SimpleDB.sln.

  3. Open the AmazonSimpleDBSamples.cs file.

  4. 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();
      
  5. 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.

VB.NET

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 following sample: <sdb home>/amazon-simpledb-2007-11-07-vbnet-library/src/Amazon.SimpleDB.sln.

  3. Open the AmazonSimpleDBSamples.vb file.

  4. 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:

      Dim accessKeyId As String = "<Your Access Key ID>"
      Dim secretAccessKey As String = "<Your Secret Access Key>"
      Dim service As AmazonSimpleDB = New AmazonSimpleDBClient(accessKeyId, secretAccessKey)
      

      Then, remove comment marks from the following line:

      Dim service As AmazonSimpleDB = 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:

      Dim accessKeyId As String = "<Your Access Key ID>"
      Dim secretAccessKey As String = "<Your Secret Access Key>"
      Dim service As AmazonSimpleDB = New AmazonSimpleDBClient(accessKeyId, secretAccessKey)
      

      Then, make sure the following line is commented out:

      Dim service As AmazonSimpleDB = New AmazonSimpleDBMock()
      
  5. Save the file.

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.