IBM custom tags for JSP application database access

The following tags are IBM custom tags that you can use in your JSP application to access a DB2 Everyplace database.

<tsx:dbconnect>

Description
This tag establishes a connection to a specified DB2 Everyplace database using the DB2 Everyplace JDBC driver.

Syntax
<tsx:dbconnect 
id="connection_id"
driver="com.ibm.db2e.jdbc.DB2eDriver"
url="jdbc:db2e:database"
userid="db_user"
passwd="user_password">
</tsx:dbconnect>

Attributes
The five attributes for this tag are:

Example
<tsx:dbconnect 
id="conn"
driver="com.ibm.db2e.jdbc.DB2eDriver"
url="jdbc:db2e:sample/data/" >
</tsx:dbconnect>

<tsx:dbquery>

Description
This tag submits a query to the database using the connection specified through the <tsx:dbconnect> tag and produces a java.sql.ResultSet object in which the cursor points to the first row of the result set. You can reference this result set using the identifier of this query and the DB2 Everyplace JDBC interface for java.sql.ResultSet.

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

Attributes
The attributes for this tag are:

Parameter
The valid parameter for this tag is:

Example
<tsx:dbquery id="Query1DBBean" connection="conn">
select <%= request.getParameter("column") %> from vnperson
</tsx:dbquery>

<tsx:dbmodify>

Description
This tag submits a command to modify data in the database using the connection specified through the <tsx:dbconnect> tag. There is no result for this tag.

Syntax
<tsx:dbmodify connection="connection_id">
modify_command
</tsx:dbmodify>

Attribute
The attribute for this tag is:

Parameter
The valid parameter for this tag is:

Example
<tsx:dbmodify connection="conn">
update vnperson set Name = '<%=Name%>' where ID = '<%=id%>'
</tsx:dbmodify>

<tsx:repeat>

Description
Use this tag to loop through each row in the query results. The start and stop attributes control the looping process. If you do not specify the start and stop attributes, the loop terminates when the cursor of the result set, which is referenced by the <tsx:getProperty> tag, reaches the end of the result set. This tag can be nested.

Syntax
<tsx:repeat index="name" start="starting_index" stop="ending_index">
repeat_block
</tsx:repeat>

Attributes
The attributes for this tag are:

Parameter
The valid parameter for this tag is:

Example
<TABLE border="1">
<TR>
<TH>Name</TH>
</TR>
 
<tsx:repeat>
<TR>
<TD>
<tsx:getProperty name="Query1DBBean" property="Name" />
</TD>
</TR>
</tsx:repeat>
</TABLE>

<tsx:getProperty>

Description
This tag retrieves the value of a ResultSet bean to be displayed in a JSP page (that is, the HTML result page). If you place this tag inside a <tsx:repeat> block tag, the cursor of the ResultSet bean advances to the next row each time the repeat block is processed.

Syntax
<tsx:getProperty name="bean_name" property="property_name" />
 

Attributes
The attributes of this tag are:

Example
<tsx:getProperty name="Query1DBBean" property="FIRSTNAME" />
 

Related concepts

Related tasks

Related reference