16.10.2015 Views

Getting Startedwith pureQuery

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 6 – The Client Optimizer: <strong>pureQuery</strong> for Existing Applications 113<br />

There are several ways to specify <strong>pureQuery</strong> properties. The most common ways are in a<br />

properties file and as the value of the IBM Data Server Driver for JDBC and SQLJ property<br />

pdqProperties. For each property, <strong>pureQuery</strong> looks for that property in several<br />

locations, in a particular order. <strong>pureQuery</strong> uses the first value that it finds. If <strong>pureQuery</strong><br />

does not find the property, <strong>pureQuery</strong> uses the default value of that property. The following<br />

lists describe the standard approaches for specifying <strong>pureQuery</strong> properties.<br />

Connection through a DataSource object: If the application creates a connection to the<br />

database by using a javax.sql.DataSource object, <strong>pureQuery</strong> searches for <strong>pureQuery</strong><br />

properties in these locations, in the order in which they are listed.<br />

1. A file named pdq.dataSourceName.properties in your application classpath,<br />

where dataSourceName represents the name of the DataSource object<br />

2. A file named pdq.appwide.properties in your application classpath<br />

3. The value of the property pdqProperties in the DataSource object. The<br />

implementations of javax.sql.DataSource that the IBM Data Server Driver for<br />

JDBC and SQLJ provides, as well as those that <strong>pureQuery</strong> provides, have a<br />

method setPdqProperties(String) that you can use for setting this. When<br />

you specify <strong>pureQuery</strong> properties in this way, you do not need to include the<br />

“pdq.” in the property names.<br />

4. A file named pdq.properties in the classpath that indicates the location of the<br />

JDBC driver.<br />

Connection through the DriverManager class: If the application creates a connection<br />

to the database by using the java.sql.DriverManager class, <strong>pureQuery</strong> searches<br />

<strong>pureQuery</strong> properties in these locations, in the order in which they are listed.<br />

1. The value of the property pdqProperties in the URL. When you specify<br />

<strong>pureQuery</strong> properties in this way, you do not need to include the “pdq.” in the<br />

property names.<br />

2. A java.util.Properties object that is passed as a parameter to a<br />

java.sql.DriverManager.getConnection method. When you specify<br />

<strong>pureQuery</strong> properties in this way, you do not need to include the “pdq.” in the<br />

property names.<br />

3. A file named pdq.properties in the classpath.<br />

If you use a properties file to specify <strong>pureQuery</strong> properties, each line of the file should<br />

contain the name of a property, then an equal sign (=), and finally the value for that<br />

property. If you want a line in a properties file to be a comment that <strong>pureQuery</strong> ignores,<br />

make # the first character of the line. The backslash character (\) is an escape character,<br />

so if you want to use a backslash in the value of a property, you need to specify two<br />

backslashes (\\). Listing 6.1 provides an example of a properties file that specifies the<br />

value C:\path\captureFile.pdqxml for the property pdq.<strong>pureQuery</strong>Xml, the value

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

Saved successfully!

Ooh no, something went wrong!