16.10.2015 Views

Getting Startedwith pureQuery

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

116<br />

<strong>Getting</strong> Started with <strong>pureQuery</strong><br />

6.5.2.1 Setup the <strong>pureQuery</strong> properties<br />

We will specify our <strong>pureQuery</strong> properties in a file named<br />

pdq.dataSourceName.properties. The class hrm.HRMDataSourceFactory<br />

defines the javax.sql.DataSource object that Human Resources Manager uses. The<br />

name of the DataSource that the application uses is<br />

DataSourceHumanResourcesManager. Therefore, the name of our properties file is<br />

pdq.DataSourceHumanResourcesManager.properties. Locate this file in the src<br />

directory of the project, and change it so that it contains the required properties. Listing 6.2<br />

shows the new contents of the file. Modify the path of the <strong>pureQuery</strong>Xml file so that the<br />

path provides an appropriate location on your computer. In the listing, the line for the<br />

pdq.<strong>pureQuery</strong>Xml property wraps onto two lines. This is only so that it will fit on the<br />

page; do not include any line breaks in the value of the property.<br />

pdq.captureMode=ON<br />

pdq.<strong>pureQuery</strong>Xml=<br />

C:\\pathOfWorkspace\\<strong>Getting</strong>StartedWithPureQuery\\<strong>pureQuery</strong>Folder\\captureFile.pdqxml<br />

Listing 6.2 - The properties to set in your properties file<br />

6.5.2.2 Run the application<br />

Your application now has the <strong>pureQuery</strong> properties set correctly, and it has pdq.jar and<br />

pdqmgmt.jar in the classpath. When we run the application, <strong>pureQuery</strong> should capture<br />

the SQL statements that the application executes. Run<br />

test.TestHumanResourcesManager as a Java application. When it has finished,<br />

refresh your project and look for the capture file that you specified in your properties. An<br />

error will probably appear because we have not yet specified a root package name for the<br />

new <strong>pureQuery</strong>Xml file. We will do that in the next section.<br />

6.6 Processing the <strong>pureQuery</strong>Xml file with the Configure utility<br />

After you have used <strong>pureQuery</strong> to capture a <strong>pureQuery</strong>Xml file, you must configure it with<br />

the <strong>pureQuery</strong> Configure utility. The Configure utility modifies the specifications of the SQL<br />

statements so that they can be bound in the database. The utility also performs checks to<br />

ensure that certain aspects of the file are valid. You can customize how the utility<br />

configures a <strong>pureQuery</strong>Xml file by specifying options.<br />

Anytime you create or change a <strong>pureQuery</strong>Xml file, it is very important that you process it<br />

with the Configure utility before you bind it or use it during execution. If you do not, the<br />

statement declarations in the file could be in an invalid state that could cause unexpected<br />

results. If you are using a <strong>pureQuery</strong>-enabled project in IBM Optim Development Studio,<br />

you must specify the options that the Configure utility should use, but IBM Optim<br />

Development Studio runs the Configure utility automatically. If you are not, you must run<br />

the Configure utility from the command line.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!