Recreating database tables from the exported table data definition language
When the WAS deployment tooling deploys an EJB jar file containing container-managed persistence (CMP) enterprise beans, it selects the target database and creates a corresponding Table.ddl file. This file contains the SQL statement necessary to generate the database table for the CMP beans.
The following steps demonstrate the process for creating tables in DB2 .
- Extract the Table.ddl file from the CMP enterprise bean JAR file and save it on the database server.
- (dist) Save the file to a working directory, such as C:\temp, on the DB2 machine.
- (zos) Save the file to a temporary directory on the work station. Transfer the file to a data set on the DB2 for z/OS system.
- (iseries) Save the file to a working directory in the integrated file system on the DB2 UDB for iSeries server.
- Run the Table.ddl file.
- (dist) Run the command C:\temp>db2cmd, replacing C:\temp with your chosen directory. A DB2 command window is displayed, in which you enter the following commands (replacing C:\temp with the chosen directory):
- C:\temp>db2 connect to your_db_name
- C:\temp>db2 -tf Table.ddl //This command runs and creates tables for the CMP enterprise bean.
- C:\temp>db2 disconnect all
Note: If we run DB2 on supported UNIX systems, use these same commands. Run them from a user with permissions for DB2, rather than from a DB2 command window.
- (zos) Data set as the input data set to SPUFI, and run the program.
- (iseries) Add an SQL CREATE statement to the Table.ddl file, then run the file:
- Start iSeries Navigator.
- Expand the iSeries icon for the system where to create the database file.
- Expand Database, and right-click on the system database.
- Select Run SQL Scripts...
- Select File > Open.
- Navigate to the Table.ddl file that you extracted, and select Open.
- Create a database, or collection, in the file by typing the following SQL statement as the first statement in the Table.ddl file:
CREATE COLLECTION collection ;where collection is the name of the database.
- Select Run > All to run all of the commands contained within the Table.ddl file.
- Select View > Job Log... and verify that the table was created successfully.
- Select File > Save to save the database.
Results
The database tables are created.