Configuration required for using DB2SPSample

This article walks you through the process of setting up a DB2 stored procedure to set the db-userid and db-password entries.

Advanced edition - single server configuration

  1. Start the administrative server.
  2. Start the thin administrative client.
    1. Expand Resources
    2. Expand JDBC Drivers
    3. Expand Db2JdbcDriver
    4. Select Data Sources
    5. Click New
    6. Enter name: SoapSamplesDS
    7. Enter JNDI name: SoapSamplesDS
    8. Enter database name: sample
    9. Enter default userID: < enter the name of your DB2 user/instance owner ID>
    10. Enter default password: < enter the name of your DB2 user/instance owner password>
      Note:   If you do not specify your user ID and password through this interface, you must specify them in the deployment descriptor.
    11. Click OK
    12. Click Save in the Browser toolbar
    13. Click OK
  3. Stop the administrative server and then restart it.

Advanced edition - multi-server configuration (using the "Create Data Source" wizard)

  1. Start the administrative client
  2. Create a new datasource using the DB2 driver and by entering the following values in the Create Datasource Wizard:
  3. Click the resources tab
  4. Expand the list of entries under this tab
  5. Expand the list of JDBC providers
  6. Expand Sample DB Driver
  7. Select datasources
  8. Select SoapSamplesDS
  9. Enter default userID: < enter the name of your DB2 user/instance owner ID>
  10. Enter default password: < enter the name of your DB2 user/instance owner password>
    Note:   If you do not specify your user ID and password through this interface, you must specify them in the deployment descriptor.
  11. In the field for the JNDI name, remove the "jdbc/" entry that is affixed to SoapSamplesDS by the wizard.
    (Ensure the JNDI name is just SoapSamplesDS)
  12. Click Apply

Advanced edition - multi-server configuration (not using the "Create Data Source" wizard)

  1. Start the administrative client
  2. Click the resources tab
  3. Expand the list of entries under this tab
  4. Expand the list of JDBC providers
  5. Expand Sample DB Driver
  6. Select datasources
  7. Right click New
  8. Enter the following values:
  9. Click OK

Setting up DB2

Your install of DB2 must include the database, the development kit, and the client code. Once the DB2 database is installed with those options, perform the following steps to configure DB2:

  1. Access the DB2 sample database named "sample." You can access the DB2 sample database in one of two ways:
  2. Install the DB2 sample stored procedure prototypes by performing the following steps:
    1. On Windows NT, with a DB2 administrator login,
      click Start -> IBM DB2 -> Command window
    2. On UNIX platforms, enter su - <your DB2 user/instance owner ID >
    3. On Windows NT, if you installed DB2 in c:\sqllib, enter
      cd c:\sqllib\samples\java
    4. On UNIX platforms, enter
      cd ~/sqllib/samples/java
    5. On either platform, enter in the command window:
      db2 connect to sample
    6. On either platform, enter in the command window:
      db2 -td@ -vt Spcreate.db2
      (This command loads a script containing the procedure prototypes into DB2.)
  3. Compile and install the procedure implementations by performing the following steps:
    1. On Windows NT, enter:
      <WAS_HOME>\java\bin\javac Spserver.java
    2. On UNIX platforms, enter:
      <WAS_HOME>/java/bin/javac Spserver.java
    3. After Spserver.java compiled successfully, on Windows NT, enter:
      copy Spserver.class c:sqllib\function
    4. After Spserver.java compiled successfully, on UNIX platforms, enter:
      cp Spserver.class <db2instance owner > /sqllib/function
    5. Verify your procedures installed successfully.
  4. Note:   If you are running on a UNIX platform some steps, such as compiling the Spserver.java file and copying the Spserver.class file, must be performed as root. If you want to perform these steps as the DB2 instance owner instead of root, change the mode of the directories to "write access."