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.

130<br />

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

reducing the cache-hit rate. Having a large number of distinct statements that are<br />

generated during runtime might also prevent you from being able to have your application<br />

run all SQL statements statically, since it might not be feasible to capture every statement<br />

that could execute.<br />

6.10.2 How to use <strong>pureQuery</strong> SQL literal substitution<br />

You can use the Client Optimizer to replace the literal values in SQL statements with<br />

parameter markers, thereby potentially improving the security and performance of your<br />

application. This is easy to do by setting a property, and it does not require changes to<br />

your application.<br />

To use the literal substitution feature for static or captured-only execution, you must set the<br />

<strong>pureQuery</strong> property pdq.sqlLiteralSubstitution. This property can have one of<br />

three values: ENABLE, DISABLE, and NOT_SET. NOT_SET is the default value. The<br />

effects of the property depend on whether you are capturing to create a <strong>pureQuery</strong>Xml file<br />

or executing while specifying a <strong>pureQuery</strong>Xml file. In general, use the value ENABLE if you<br />

want to use literal substitution and the value DISABLE if you do not. The lists below<br />

describe the specific meanings of the different values.<br />

These are the effects of the different values during capture:<br />

• ENABLE: <strong>pureQuery</strong> substitutes literal values with parameter markers in<br />

as many of the statements that it captures as possible. <strong>pureQuery</strong> then<br />

executes the parameterized versions of these statements instead of the<br />

original versions. Consequently, the database and the JDBC driver are<br />

only aware of their parameterized forms.<br />

• DISABLE: <strong>pureQuery</strong> does not replace literal values; it captures SQL<br />

statements how they are executed by the application. The maximum<br />

number of SQL statements containing literals that <strong>pureQuery</strong> captures<br />

can be limited by the value of the <strong>pureQuery</strong> property<br />

pdq.maxNonParmSQL, if that property is set.<br />

• NOT_SET: If the <strong>pureQuery</strong>Xml file does not already exist, <strong>pureQuery</strong><br />

does not replace literal values. If the <strong>pureQuery</strong>Xml already exists (which<br />

means this is an incremental capture), <strong>pureQuery</strong> uses the value that was<br />

set during the previous capture.<br />

These are the effects of the different values when you specify a <strong>pureQuery</strong>Xml file during<br />

static or dynamic execution:<br />

• ENABLE: <strong>pureQuery</strong> substitutes literal values with parameter markers in<br />

the SQL statements that execute, and tries to match the statements to the<br />

parameterized statements in the file. If <strong>pureQuery</strong> cannot find a matching<br />

parameterized statement, <strong>pureQuery</strong> tries to match the original statement

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

Saved successfully!

Ooh no, something went wrong!