Now I want each pooled object to contain a Connection and two PreparedStatements. Figure 4 shows the database access object containing the database resources I want to pool. Finally, the application has to change to get a database access object and specify which resource from the object it wants to use. As you can see, I am gaining performance through reuse. This is key.
Most applications contain critical sections of code.
An application typically spends 80 to 90 percent of its execution time in only 10 to 20 percent of the code. If you have 10,000 SQL statements used in an application, you don't want to pool all of them. You want to find and pool the SQL statements that are used in your application's critical sections of code. I used this model to build an e-commerce application using servlets. There are many other SQL statements, such as admin requests to add new books and other less common tasks.