Name

SQLCommandBean

Synopsis

The SQLCommandBean class is a bean for executing SQL statements intended to encapsulate database access and to be used by the database custom actions and other classes. 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.

Synopsis

Class name:

com.ora.jsp.beans.sql.SQLCommandBean

Extends:

None

Implements:

None

Description

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.List

Write

A List with values for all placeholders in the SQL statement

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

public javax.servlet.jsp.jstl.sql.Result executeQuery( )

throws java.sql.SQLException

Returns a JSTL Result object with the result of executing a SELECT statement.

public int executeUpdate( ) throws java.sql.SQLException

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

Get JavaServer Pages, Second Edition 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.