Java Reference
In-Depth Information
Here we see the same fields we saw when we were using this tag to insert a row
into a database table. In this case the Variable Name field indicates the number of
rows that were updated by the UPDATE statement. When clicking the OK button, the
following markup is generated in the location where we dropped the DB Update
palette item.
<sql:update var="updatedRows" dataSource="jdbc/sample">
UPDATE customer
SET zip = '22033'
WHERE name LIKE ?
</sql:update>
Since we have a parameter in our query, we need to add a <sql:param> tag inside
our <sql:update> tag.
<sql:update var="updatedRows" dataSource="jdbc/sample">
UPDATE customer
SET zip = '22033'
WHERE name LIKE ?
<sql:param value="Ensode%"/>
</sql:update>
Just like we did in our last page, we can add a DB Report item from the NetBeans
palette so that we can visually inspect the effect of the <sql:update> tag. After
doing so, the body of our page looks like this:
<body>
<h2>Hello World!</h2>
<sql:update var="updatedRows" dataSource="jdbc/sample">
UPDATE customer
SET zip = '22033'
WHERE name LIKE ?
<sql:param value="Ensode%"/>
</sql:update>
<sql:query var="result" dataSource="jdbc/sample">
SELECT customer_id, name, discount_code, zip
FROM customer where name like ?
<sql:param value="Ensode%" />
</sql:query>
<table border="1">
<!-- column headers -->
<tr>
<c:forEach var="columnName"
 
Search WWH ::




Custom Search