77 lines
3.0 KiB
HTML
77 lines
3.0 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<LINK rel="stylesheet" type="text/css" href="../../../rzahg/ic.css">
|
|
|
|
<title><tsx:dbmodify></title>
|
|
</head>
|
|
|
|
<BODY>
|
|
<!-- Java sync-link -->
|
|
<SCRIPT LANGUAGE="Javascript" SRC="../../../rzahg/synch.js" TYPE="text/javascript"></SCRIPT>
|
|
|
|
<h5><a name="jspmod"></a><tsx:dbmodify></h5>
|
|
|
|
<p>Use the <tsx:dbmodify> syntax to establish a connection to a database and then add records to a database table.</p>
|
|
|
|
<p>The <tsx:dbmodify> tag:</p>
|
|
|
|
<ul>
|
|
<li>Refers to a <tsx:dbconnect> in the same JSP file and uses the information provided by that database connection to determine the database URL and driver. The user ID and password are also obtained from the <tsx:dbconnect> if those values are provided in the <tsx:dbconnect>.</li>
|
|
|
|
<li>Establishes a new connection.</li>
|
|
|
|
<li>Updates a table in the database.</li>
|
|
|
|
<li>Closes the connection (releases the connection resource).</li>
|
|
</ul>
|
|
|
|
<p>The <tsx:dbmodify> syntax is:</p>
|
|
|
|
<pre><tsx:dbmodify connection="<em>connection_id</em>" >
|
|
|
|
<!-- Any valid database update commands can be ->
|
|
<!-- placed within the tsx:dbmodify tag. Any other ->
|
|
<!-- syntax, including HTML comments, are not valid. ->
|
|
|
|
</tsx:dbmodify></pre>
|
|
|
|
<p>This list describes the attributes and their values:</p>
|
|
|
|
<ul>
|
|
<li><p><strong>connection</strong>
|
|
<br>The identifier of a <tsx:dbconnect> in this JSP file. That <tsx:dbconnect> provides the database URL, driver name, and (optionally) the user ID and password for the connection.</p></li>
|
|
|
|
<li><p><em>Database commands</em>
|
|
<br>For more information about database commands, see this resource:</p>
|
|
<ul>
|
|
<li><a href="../../../icbase/db2/v5r2rbafzmst02.htm" target="_blank">DB2 Universal Database for iSeries SQL Reference (V5R2)</a></li>
|
|
</ul></li>
|
|
</ul>
|
|
|
|
<p>In the following example, a new employee record is added to a database. The values of the fields are based on user input from this JSP and referenced in the database commands using the <tsx:getProperty> tag.</p>
|
|
|
|
<pre><% String empno = request.getParameter("EMPNO"); %>
|
|
<% String firstnme = request.getParameter("FIRSTNME"); %>
|
|
<% String midinit = request.getParameter("MIDINIT"); %>
|
|
<% String lastname = request.getParameter("LASTNAME"); %>
|
|
<% String workdept = request.getParameter("WORKDEPT"); %>
|
|
<% String edlevel = request.getParameter("EDLEVEL"); %>
|
|
|
|
<tsx:dbmodify connection="conn" >
|
|
INSERT INTO WSDEMO.EMPLOYEE
|
|
(EMPNO,FIRSTNME,MIDINIT,LASTNAME,WORKDEPT,EDLEVEL)
|
|
VALUES
|
|
( '<%=empno%>',
|
|
'<%=firstnme%>',
|
|
'<%=midinit%>',
|
|
'<%=lastname%>',
|
|
'<%=workdept%>',
|
|
<%=edlevel%> )
|
|
</tsx:dbmodify></pre>
|
|
|
|
</body>
|
|
</html>
|
|
|