18.8. Connection Pooling: A Case Study

OK, so we have a ConnectionPool class: what good does it do us? Let's find out. Listing 18.20 presents a simple servlet that allocates a ConnectionPool in its init method, then, for each request, performs a simple database lookup and places the results in an HTML table. Listing 18.21 and Figure 18-6 show an HTML document that places a copy of this servlet in each of 25 frame cells. Since the servlet stipulates that it not be cached by the browser, this document results in 25 near simultaneous HTTP requests and thus 25 near simultaneous database lookups using connection pooling. This request pattern is similar to what would occur on high-traffic sites even when only a single servlet is used for each page. ...

Get Core Servlets and JavaServer Pages™ now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.