Name

SQLCommandBean

Synopsis

Class Name:

com.ora.jsp.sql.SQLCommandBean

Extends:

None

Implements:

None

Description

The SQLCommandBean class is a bean for executing SQL statements, and is used by the database custom actions. It can also be used in a servlet to simplify the database access code. The bean has three properties that can be set: connection, sqlValue, and values. The connection and sqlValue properties must always be set before calling one of the execute methods. If the values property is set, the sqlValue property must be a SQL statement with question marks as placeholders for the value objects in the values property. The bean properties are described in Table 3.24.

Table C-24. com.ora.jsp.SQLCommandBean Properties

Property Name

Java Type

Access

Description

connection
java.sql.Connection

write

The database Connection to use.

sqlValue
String

write

The SQL statement to execute, optionally with question marks as placeholders for values.

values
java.util.Vector

write

A Vector with Value objects (see the next section, Section 3.5.1).

The SQLCommandBean class also provides the following regular methods for executing the SQL statement.

public java.util.Vector executeQuery( ) throws java.sql.SQLException, UnsupportedTypeException

Returns a Vector with Row objects as the result of executing a SELECT statement.

public int executeUpdate( ) throws java.sql.SQLException, UnsupportedTypeException

Returns the number of rows affected by a DELETE, INSERT, or UPDATE

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.