Share jOOQ on Facebook
Share jOOQ on Twitter
The jOOQ User Manual. Multiple Pages : SQL building : Bind values and parametersprevious : next

This page in other versions: 3.4 | 3.3 | 3.2 | Old, end-of-life releases: 3.1 | 3.0 | 2.6 | 2.5

Bind values are used in SQL / JDBC for various reasons. Among the most obvious ones are:

  • Protection against SQL injection. Instead of inlining values possibly originating from user input, you bind those values to your prepared statement and let the JDBC driver / database take care of handling security aspects.
  • Increased speed. Advanced databases such as Oracle can keep execution plans of similar queries in a dedicated cache to prevent hard-parsing your query again and again. In many cases, the actual value of a bind variable does not influence the execution plan, hence it can be reused. Preparing a statement will thus be faster
  • On a JDBC level, you can also reuse the SQL string and prepared statement object instead of constructing it again, as you can bind new values to the prepared statement. jOOQ currently does not cache prepared statements, internally.

The following sections explain how you can introduce bind values in jOOQ, and how you can control the way they are rendered and bound to SQL.

The jOOQ Logo