InfoCenter Home >
4: Developing applications >
4.2: Building Web applications >
4.2.2: Developing JSP files >
4.2.2.3: Overview of JSP file content >
4.2.2.3.8: IBM extensions to JSP .91 syntax >
4.2.2.3.8.2: JSP .91 syntax: JSP tags for database access >
4.2.2.3.8.2.3: JSP .91 syntax: <DBQUERY> tag
4.2.2.3.8.2.3: JSP .91 syntax: <DBQUERY> tag
<!-- SELECT commands and (optional) JSP syntax can be placed within the DBQUERY tag. -->
<!-- Any other syntax, including HTML comments, are not valid. -->
<dbquery id="query_id" connection="connection_id" limit="value" >
</dbquery>
where:
- id
The identifier of this query. The scope is the JSP file. This identifier is used to reference the query, for example, from the <INSERT> tag to display query results.
The id becomes the name of a bean that contains the results set. The bean properties are dynamic and the property names are the names of the columns in the results set. If you want different column names, use the SQL keyword for specifying an alias on the SELECT command. In the following example, the database table contains columns named FNAME and LNAME, but the SELECT statement uses the AS keyword to map those column names to FirstName and LastName in the results set:
Select FNAME, LNAME AS FirstName, LastName from Employee where FNAME='Jim'
- connection
The identifier of a <DBCONNECT> tag in this JSP file. That <DBCONNECT> tag provides the database URL, driver name, and (optionally) the user ID and password for the connection.
- limit
An optional attribute that constrains the maximum number of records returned by a query. If the attribute is not specified, no limit is used and the effective limit is determined by the number of records and the system caching capability.
- SELECT command and JSP syntax
Because the <DBQUERY> tag must return a results set, the only valid SQL command is SELECT. Refer to your database documentation for information about the SELECT command. See other sections of this document for a description of JSP syntax for variable data and inline Java code.
|
|