<tsx:dbquery>

Use the <tsx:dbquery> syntax to establish a connection to a database, submit database queries, and return the results set.

The <tsx:dbquery> tag:

The <tsx:dbquery> syntax is:

<tsx:dbquery id="query_id" connection="connection_id" limit="value" >

  <%-- SELECT commands and (optional) JSP syntax can be --%>
  <%-- placed within the tsx:dbquery tag. Any other     --%>
  <%-- syntax, including HTML comments, are not valid.  --%>

</tsx:dbquery>

This list describes the attributes and their values:

In the following example, a database is queried for data about employees in a specified department. The department is specified using the <tsx:getProperty> to embed a variable data field. The value of that field is based on user input.

<% String   workdept = request.getParameter("WORKDEPT"); %>

<tsx:dbquery id="qs2" connection="conn" >
   select * from WSDEMO.EMPLOYEE  where  WORKDEPT= '<%=workdept%>'
</tsx:dbquery>

Displaying query results

To display the query results, use the <tsx:repeat> and <tsx:getProperty> syntax. The <tsx:repeat> loops through each of the rows in the query results. The <tsx:getProperty> uses the query results object (for the <tsx:dbquery> syntax whose identifier is specified by the <tsx:getProperty> bean attribute) and the appropriate column name (specified by the <tsx:getProperty> property attribute) to retrieve the value. For example:

<tsx:repeat>
<tr>
<td>
  <tsx:getProperty name="empqs" property="EMPNO" />
  <tsx:getProperty name="empqs" property="FIRSTNME" />
  <tsx:getProperty name="empqs" property="WORKDEPT" />
  <tsx:getProperty name="empqs" property="EDLEVEL" />
</td>
</tr>
</tsx:repeat>

The JSP10employeeRepeatResults.jsp example illustrates the syntax of the <tsx:getProperty> tag.