Chapter 17. Developing Database Access Components
In this final chapter, we look at more examples of how to develop custom actions, namely the database custom actions introduced in Chapter 9.
Before digging into the code for these actions, a number of
fundamental Java database access features are discussed. First, we
take a look at the JDBC Connection
class, and how
pooling Connection
objects helps solve a number of
common problems. We look at two ways to provide connection pooling
capabilities to an application: with JDBC 2.0, and by letting a JDBC
1.0 connection pool simulate a JDBC 2.0 pool. The purpose of a
connection pool is to be able to share database connections between
all components of an application. The approach discussed in this
chapter is to use an application initialization servlet that makes
the pool available to all servlets and JSP pages.
No matter if you use a servlet or a custom action in a JSP page to access the database, there are a number of things to think about. We look at a generic database access bean and related classes that take care of datatype issues and make the result of a query easy to access. Next, we look at how the bean is used by the database access custom actions described in Chapter 9. You can also use the bean directly in servlets, as described in Chapter 15, or in your own application-specific database access actions. The last section contains an example of an application-specific custom action using the bean.
To really appreciate the material ...
Get Java Server Pages now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.