Configure the server: Create the database tables

You must create the underlying database tables required by the HitCount sample application. A Data Definition Language (DDL) script is created for each entity enterprise bean when the bean is packaged into an EJB module using the application assembly tool. This DDL script is named Table.ddl, and it is stored in the enterprise bean's JAR file after it has been packaged in the EJB module. This DDL script contains the required commands for creating the underlying database table for the entity bean.

To use this generated script file to create the database table on your iSeries server, follow these steps:

  1. Extract the Table.ddl file from your EJB Module.

    1. Use a file compression utility to open your Deployed_HitCount.ear file.
    2. Select META-INF/Table.ddl.
    3. Extract the file to the /hcsample directory.

  2. Start iSeries Navigator.

  3. Expand the iSeries icon for the system where you want to create the database file.

  4. Expand Database, and right-click the system database.

  5. Select Run SQL Scripts...

  6. Select the File -> Open menu item.

  7. Change the Files of type view to All Files ("*.*").

  8. Navigate to the Table.ddl file that was extracted to the META-INF folder in a previous step and select Open.

  9. In the file, create a database (or collection) used for the HitCount sample application. Specify the following SQL statement as the first statement in the file:

    CREATE COLLECTION HITCOUNTDB;

  10. You must also qualify the tables and constraints in the SQL statements with the database (or collection) name. Edit the SQL statements to contain the following values:

    CREATE TABLE HITCOUNTDB.INCREMENT
    ALTER TABLE HITCOUNTDB.INCREMENT
    ADD CONSTRAINT HITCOUNTDB.PK_INCREMENT PRIMARY KEY (PRIMARYKEY);

  11. Select the Run -> All menu item to execute all commands contained within the script.

  12. Select the View -> Job Log... menu item and verify that the table was created successfully.

  13. Select the File -> Save menu item to save the file.

  14. Exit the Run SQL Scripts application.

  15. Exit iSeries Navigator.

Create the proper authorities

For the HitCount sample application and database tables, it is easiest to grant all users authority to the database tables. Alternatively, you could grant authority to just QEJBSVR. Run the following commands on an iSeries server command line to change authority to *ALL for all users:

Because all users of the database tables now have authority, there is no need to a specify a user ID and password in the data source. The data source accesses the tables using the QEJBSVR user profile, which it is running in.

Continue Next: Configure the instance