Chapter 39. Tuning JDBC for SQL Server

 

Jungsun Kim

When I look at the queries sent to SQL Server via JDBC, the query methods are often not optimized for SQL Server, resulting in performance issues. This problem has occurred in all of my customers’ systems that use JDBC to access SQL Server. JDBC-based applications will have performance issues if appropriate steps aren’t taken to correct the problems caused by JDBC.

For the last few years, I’ve diagnosed many performance problems for Java-based applications using the JDBC driver to access SQL Server. Doing so has required a lot of trial-and-error testing, but eventually I was able to come up with techniques to help resolve the performance issues.

In this chapter, I’ll share what I’ve learned, so if you face similar problems, you’ll know how to approach solving them.

JDBC performance tuning can be effective

The best way to start out is to review a recent case. The system consisted of Apache Tomcat, SQL Server, and Microsoft JDBC. As part of diagnosis and performance tuning, I decided to change a single attribute in Tomcat to modify the behavior of JDBC. I’ll tell you about this change in the next section.

Figures 1 and 2 display the resource usage by duration, CPU, and logical I/Os for a given time period while running a common workload. Figure 1 shows the resource usage values before the change, and figure 2 shows the values after the change.

Figure 1. Resource usage before tuning
Figure 2. Resource usage after tuning

Recommendations for tuning jTDS configuration

Unicode character issues

API cursor issues

ResultSet Type issue

Prepared statement mechanism issue

Controlling global configuration

Summary

About the author