Using a Generic Database Bean
All the
database custom action
tag handler classes described later in this chapter are based on a
generic database bean named
com.ora.jsp.sql.SQLCommandBean
. This bean uses a number of other
classes. Figure 17.3 shows the relationship between
all these classes.

Figure 17-3. The SQLCommandBean and related classes
The SQLCommandBean takes care of setting all
values in a JDBC
java.sql.PreparedStatement
and executing the statement. For
SELECT statements, it also processes the result by
creating com.ora.jsp.sql.Row objects containing a
com.ora.jsp.sql.Column object for each column in
the result. The rows returned by the SELECT
statement are returned to the caller as a
java.util.Vector
with Row objects.
The EmployeeRegistryBean described in Chapter 15 is one example of how to use this bean, and
other examples follow in this chapter. Let’s look at each class
in detail, starting with the SQLCommandBean
itself.
The SQLCommandBean and Value Classes
The SQLCommandBean
has three write-only properties. Example 17.3 shows
the beginning of the class file with the setter methods.
Example 17-3. SQLCommandBean Property Setter Methods
package com.ora.jsp.sql; import java.util.*; import java.sql.*; import com.ora.jsp.sql.value.*; public class SQLCommandBean { private Connection conn; private String sqlValue; private Vector values; private boolean isExceptionThrown = false; ...Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access