Chapter 16. Tuning JDBC

JDBC (Java Database Connectivity) consists of a set of APIs and specifications that allow any Java application to connect to any JDBC-enabled data repository that executes SQL statements. Usually, this data repository is a relational database (since that is what JDBC was designed for), but the JDBC protocol does not restrict connections to relational databases.

Connecting to a database with JDBC is essential for many applications. This chapter shows you how to identify the bottlenecks in your communications with the database and how to improve the performance of those communications.

The chapter is divided into two sections. The first section, Section 16.1, provides extensive details on building a tool that allows you to determine whether your JDBC communications cause bottlenecks and, if so, which JDBC statements are to blame. If you have already identified JDBC bottlenecks in your application, you can skip this first section. Note that an open source tool, P6Spy (http://www.provision6.com/index.htm), helps identify JDBC bottlenecks by using a similar methodology.

The second section, Section 16.2, provides details on how to tune the JDBC portion of your application. In addition to JDBC-specific issues, this section addresses tuning SQL (Structured Query Language) usage, since optimizing SQL can result in a huge gain in JDBC performance.