Running the Ant script
In order to make running the DB2 SQLJ profile customizer, db2sqljcustomize, easier, you can employ an Ant script. This particular Ant script is the one that is created when the batch SQLJ ejbdeploy command is run against an EAR file.
The Ant script is run against every customization profile in every EJB JAR in the associated EAR. The script will update each EJB JAR file with the modified customization profile, and will replace the JAR files in the EAR with the modified version. This Ant script is specific to the corresponding EAR file and it modifies the existing EAR file. This Ant script runs the DB2 SQLJ profile customizer against every customization profile in every EJB JAR in the associated EAR file
Note: If you need to run the ejbdeploy command again, also run the Ant script again. You should not need to generate a new properties file, unless you have changed the number or names of the JAR files in the EAR, or unless the database backend IDs that are used in any of the JAR files have changed.
Running the script
- Run the Ant script, specifying the properties target.
ant -buildfile out.ear.xml propertiesThis creates a properties file called out.ear.properties. This file contains properties specifying default names for the packages corresponding to each customization profile in the EAR file, for example:
pkg.One.jar.DB2UDBNT_V8_1=PKG2_ pkg.Two.jar.DB2UDBNT_V8_1=PKG1_In this example, the EAR file contains two EJB JAR files, One.jar and Two.jar.
- Edit the generated properties file to change the package names. You can also specify other properties in this file, like the database URL, user or password:
url.One.jar.DB2UDBNT_V8_1=jdbc:db2://localhost:50000/dbx user.One.jar.DB2UDBNT_V8_1=dbuser password.One.jar.DB2UDBNT_V8_1=dbpassword pkg.One.jar.DB2UDBNT_V8_1=TESTurl.Two.jar.DB2UDBNT_V8_1=jdbc:db2://localhost:50000/dby pkg.Two.jar.DB2UDBNT_V8_1=WORKNote: DB2 uses only the first of seven (7) characters of the name that you specify. The DB2 SQLJ profile customizer will use the name to create four packages in the database. If you specify a name of PKG, the customizer will create packages called PKG1, PKG2, PKG3 and PKG4.
- Ensure the database tables for the enterprise beans exist in the database; otherwise, the customization step will fail.
- Make sure that DB2's db2jcc.jar is on the class path. It should have been added to the class path when DB2 V8 was installed.
Note: Starting with DB2 Version 8 fix pack 2, also add the license JAR file to the class path. The license file contained in the JAR file permits connectivity to the server. There are different license JAR files depending on the type of database server you are using:
- db2jcc_license_cu.jar - for Windows, UNIX, and Cloudscape servers
- db2jcc_license_cisuz.jar - for all servers
- db2jcc_license_c.jar - for Cloudscape servers only
In summary, the following events are the outcome of the customization step:
- Four database packages which contain the static SQL, are created, one for each isolation level
The script uses a set of default names for the packages created in the database.
- The generated customization profiles are updated
The script will update each EJB JAR file with the modified customization profile, and will replace the JAR files in the EAR with the modified version. This Ant script is specific to the corresponding EAR file and it modifies the existing EAR file. For each customization profile, there are also properties to specify the URL, user and password. By default, the properties for the customization profile are set from the global properties.
This script for a particular EAR file reads properties from two files, ejbdeploy.sqlj.properties and (by default) ear_name.properties, where ear_name is the name of the EAR file. The ejbdeploy.sqlj.properties file is common to all Ant scripts generated by the ejbdeploy command, while ear_name.properties is specific to the Ant script for the EAR. You can have the Ant script use a file other than ear_name.properties by specifying the script.property.file property when you run the script.
Tip: The ejbdeploy.sqlj.properties file is a good place to specify global properties, like your database user ID and password.Note: Notes about the updated profiles:
- They must be available to the generated code at run time.
- They must be included in the actual EJB JAR file, which is installed into WebSphere Application Server.
For information about running Ant, refer to the Apache Ant manual at ant.apache.org/manual/index.html
The updated EAR file can now be installed into WebSphere Application Server.
Parent topic
Deploying EJB applications using SQLJ for data access
Previous topic: Preliminary steps for running the DB2 SQLJ profile customizer using the Ant script
Next topic: Installing the EAR file on the server
Related concepts
DB2 SQLJ profile customizer