Name
<sql:query>
Synopsis
The <sql:query>
action executes an SQL
SELECT
statement
and saves the result in a scoped variable. The statement may contain
question marks as placeholders for values assigned by nested
<sql:param>
actions.
The action uses a connection provided by an
<sql:transaction>
action, or
transaction
action or -- if not part of a
transaction -- from the explicitly specified data source or the
data-source configuration setting. The number of rows to retrieve can
be limited explicitly or with the maximum rows configuration setting.
Syntax 1: Without a body
<sql:query sql="sqlSelectStatement
" [dataSource="dataSource
"] [maxRows="maxRows
"] [startRow="index
"] var="var
" [scope="page|request|session|application"] />
Syntax 2: With a body for parameters
<sql:query sql="sqlSelectStatement
" [dataSource="dataSource
"] [maxRows="maxRows
"] [startRow="index
"] var="var
" [scope="page|request|session|application"]><sql:param> actions
</sql:query>
Syntax 3: With a body for the statement and parameters
<sql:query [dataSource="dataSource
"] [maxRows="maxRows
"] [startRow="index
"] var="var
" [scope="page|request|session|application"]>sqlSelectStatement
<sql:param> actions
</sql:query>
Attributes
Attributename |
Java type |
Dynamic valueaccepted |
Description |
---|---|---|---|
sql |
|
Yes |
The SQL statement. |
dataSource |
|
Yes |
The data source to use. If specified as a |
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.