Binding Java applications that contain Java stored procedures

If you create one or more Java stored procedures in a Java application that is enabled for pureQuery, you can bind the application to a DB2® database. Applications that use embedded SQL that is statically bound into DB2 packages have inherent advantages in the areas of performance, reliability, security, monitoring, and administration.

Before you begin

Ensure the following requirements are met:
  • The Java project that contains the Java stored procedures must be associated with a supported DB2 database.
  • The files pdq.jar and pdqmgmt.jar must be in the build path for the Java project.

About this task

The following values are used as the default values:
  • Packages are bound into the NULLID collection.
  • The version identifier of the packages is determined by an algorithm and based on the current system time for the database.
  • The root package name is the first seven characters of the name of the execution class. Four packages are created, one for each isolation level.

You can specify the name of the package collection and the root package names and versions.

To bind a Java application that contains Java stored procedures:

Procedure

  1. If the pureQuery Outline view is not open, select Window > Show View > Other. In the Show View window, select Data > pureQuery Outline.
  2. In the Package Explorer, expand the dataAccessFolder folder in the Java project that contains the Java stored procedures.
  3. Right-click the Default.genProps file and select Data Access Development > Add or Remove Entries. In the Add or Remove Entries window, add all of the interfaces that are required for your stored procedure.
  4. In the Default.genProps file, specify the collection, root names, and versions of the DB2 packages that you want to create. Click Refresh in the pureQuery Outline view to see your changes. The view still shows only unbound packages because you have not yet performed the bind operation.
  5. Right-click the Default.bindProps file and select Data Access Development > Add or Remove Entries. In the Add or Remove Entries window, add all of the interfaces that are required for your stored procedure.
  6. In the Default.bindProps file, specify options that will apply to all of the SQL statements in the Java application when you bind them into DB2 packages.
  7. Right-click the Java project that contains the Java stored procedures, and then select Bind pureQuery Application. The Select Connection window opens so that you can choose the DB2 database that you want to use. You can choose a database that is not associated with your Java project.

    The results of the bind operation are displayed in the Console view. The view opens automatically if it is not open already.

    Any errors that the bind operation encounters are also displayed in the Console view.

  8. Modify the Java stored procedure code so that it contains the logic to set the pdq.executionMode property to static when invoking the pureQuery API. The following code segment shows an example of this logic:
    	java.util.Properties myPdqProperties = new java.util.Properties();
    	myPdqProperties.put("pdq.executionMode", "STATIC");
    	Connection con = DriverManager.getConnection("jdbc:default:connection");
    	Data d = DataFactory.getData(con,myPdqProperties);

Feedback