Before you start
The IBM Data Studio portfolio includes pureQuery, which is a high-performance, data access platform to simplify developing, managing, securing, and optimizing Java data access. It consists of development tools (delivered in Data Studio Developer), a simple and intuitive API, and a runtime (delivered in Data Studio purequery Runtime).
One of the major benefits of pureQuery in regards to optimizing and securing Java data access to DB2 data is how easy it is to develop and deploy applications that use static SQL. With static SQL, the preparation steps for executing a SQL statement occur before the application is ever executed, thus offering the opportunity for better performance at runtime. In addition, static SQL, which is always known ahead of time, is not susceptible to malicious or accidental SQL injections, a known security flaw with dynamic SQL. For more information about the performance and security benefits of static SQL, see Resources.
Previously, you needed to write your application in the pureQuery annotated-method style to use static SQL. In Version 1.2 of Data Studio Developer and Data Studio pureQuery Runtime, you can use static SQL on existing JDBC application, without having to rewrite your code, regardless of whether they implement persistence directly or use popular frameworks, such as Hibernate and JPA. This feature is sometimes called client optimization because the process for enabling the static capability occurs at the JDBC client level. We will simply call this pureQuery for JDBC applications.
The general process of enabling an application for pureQuery for JDBC applications is an iterative process consisting of the following phases:
- Planning. The purpose of the planning phase is to determine whether an application is a suitable candidate for pureQuery enablement. Even though it is conceptually possible to enable any Java application that accesses data in any DB2 data server, there are certain criteria that have to be met such as prerequisites (for example, the application runs in JRE 1.5 or above), security aspects (for example, that the DBA or data steward agrees with using database package-based security instead of table/view-based security), and so on.
- Capture. PureQuery for JDBC applications relies on information about the applications' SQL statements and its associated metadata to process them statically. During the capture phase, the necessary information is gathered and stored in a metadata file.
- Configure. To execute SQL statically, it must first be bound to a database package. Before you do that, you can configure the captured SQL file to specify, for example, how many SQL statements go into each package.
- Bind. After the package characteristics have been defined, you bind the captured SQL and its enriched metadata to one or more databases. (You can also store it into a DBRM and deploy it later.)
- Execution and validation. Upon successful completion of the previous phases, pureQuery for JDBC applications is configured to execute SQL statements statically. As part of validation, a quality assurance professional verifies that the application behaves as desired and returns the expected results.
Note: The enablement process in a typical usage scenario is an iterative process.
In this tutorial, learn how to use Data Studio Developer to enable a simple custom-developed JDBC application that is included in this tutorial. However, you can also follow this tutorial using an application of your choice that accesses DB2 data on any platform. Access to source code is not required for client optimization, but the steps in this tutorial assume you have such access.
The objective of this tutorial is to introduce you to the process of enabling an existing JDBC application for pureQuery. To keep this tutorial simple, we've supplied you with a small application that implements its persistence directly using JDBC, meets all enablement requirements, and can be easily validated.
In this tutorial you will learn how to:
- Create a sample database and import the sample JDBC application into Data Studio Developer 1.2
- Run the application using one code path and capture its SQL
- Optionally, browse the sample application's SQL and its relationship to the Java source code
- Configure and bind the captured SQL to a database package
- Run the sample application in static SQL execution mode, and validate its correct behavior
- Run the application using another code path to capture the remaining SQL; then rebind and re-run the application using static SQL execution
This tutorial is written for application developers and DBAs who have basic experience with Eclipse-based tooling.
To run the examples in this tutorial, you should have Data Studio Developer 1.2 installed. You will also need access to a DB2 data server. Download the DB2 Express-C no-charge version of DB2 for the community that offers the same core data features as DB2 LUW and provides a solid base to build and deploy applications. Refer to the Resources section for download links.



