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:
- id - Specifies the identifier of this connection. Do not
reuse this name in the JSP page. This attribute is required.
- driver - Specifies the DB2 Everyplace JDBC driver. This
attribute is required.
- url - Specifies the DB2 Everyplace database. The term
database refers to the path of the DB2 Everyplace database.
This attribute is required.
- userid - Specifies a valid user ID for the database to be
accessed. This attribute is optional.
- passwd - Specifies the user password for the userid
attribute. This attribute is required if userid is specified.
- 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:
- id - Specifies the identifier of this query. Do not reuse
this query identifier in the JSP page. This attribute is
required.
- connection - Specifies the identifier of a
<tsx:dbconnect> tag in this JSP file. This attribute is
required.
- limit - Specifies the maximum number of rows that the query can
return. This attribute is optional.
- Parameter
- The valid parameter for this tag is:
- select_SQL_statement - Specifies the SQL query that you want to
submit to the database. This SQL query statement can contain dynamic
data.
- 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:
- connection - Specifies the identifier of a
<tsx:dbconnect> tag in this JSP file. This attribute is
required.
- Parameter
- The valid parameter for this tag is:
- modify_command - Specifies the SQL command that you want to
submit to the database to modify data. This modify command can contain
dynamic data.
- 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:
- index - Specifies the identifier for the index of this
tag. This attribute is optional.
- start - Specifies the number of rows to skip before processing
the repeat block. The default is 0. This attribute is
optional.
- stop - Specifies the ending index value for this repeat
block. The default is 2,147,483,647. This attribute is
optional.
- Parameter
- The valid parameter for this tag is:
- repeat_block - Specifies the block of HTML tagging that contains
the <tsx:getProperty> tag syntax and the HTML tags used to format the
content. If you place a <tsx:getProperty> tag in the repeat
block, the cursor advances to the next row each time the repeat block is
processed.
- 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:
- name - Specifies the name of the ResultSet bean that you declared
previously using a <tsx:dbquery> tag in this JSP file.
- property - Specifies the column of the ResultSet bean to
access.
- Example
-
<tsx:getProperty name="Query1DBBean" property="FIRSTNAME" />
Zugehörige Konzepte
Zugehörige Tasks
Zugehörige Referenzen