After you bind the SQL statements in packages on a DB2® database, you can run your code
so that it executes the SQL statically.
Before you begin
- Your project must be associated with a supported DB2 database.
- The file pdqmgmt.jar must be in the build path
for your Java™ project.
Procedure
To run pureQuery code that uses static SQL statements,
follow any of these three steps:
- Modify your application so that it uses a Properties object
that sets the executionMode property to STATIC. Your
code should pass this object to the DataFactory.getData() method
when it creates an instance of the implementation of the interface.
Here is an example:
java.util.Properties myPdqProperties = new java.util.Properties();
myPdqProperties.put("pdq.executionMode", "STATIC");
data = DataFactory.getData (name_of_interface, "jdbc_URL_to_database",
"user_ID", args[0], myPdqProperties);
- Set the execution mode of the application to STATIC by
using a JVM system property.
- Right-click the implementation of your interface and
selecting Run As > Run.
- In the Run window, select the Arguments tab.
- In the VM arguments field, type -Dpdq.executionMode="STATIC"
- Click Run. The
output appears in the Console view.
- Set the execution mode of the application to STATIC by
using a file named pdq.properties. You can place this file
on the file system or in your application's classpath.
Here is
an example of a properties file. The properties are specified in pairs
of keys and values. The # symbol at the beginning of a line indicates
that the line contains a comment.
# Set the execution mode.
pdq.executionMode="STATIC"
By default, pureQuery expects the name of the file
to be pdq.properties and the location of the file to be in your application's
classpath.
If you use a different file name, place the file
in a different location, or both, follow these steps when you run
your application:
-Dpdq.configFile=path-and-file-name or resource-name
- Right-click the implementation of your interface and
selecting Run As > Run.
- In the Run window, select the Arguments tab.
- In the VM arguments field, type -Dpdq.config.file=name_of_file
- Click Run. The
output appears in the Console view.
If
you are developing a Web application, place the pdq.properties file
in your application's WEB-INF/classes folder
or in a JAR file in the WEB-INF/lib folder.
If you are developing a stand-alone application,
place the pdq.properties file in any folder or JAR file that is in
the classpath for the application.