Java Reference
In-Depth Information
The Data Source field must contain the JNDI name of the data source used to obtain
a database connection. This data source must be added as a Resource Reference to
our application's web.xml deployment descriptor as explained earlier in this chapter.
Finally, the value of the Insert Statement field allows us to specify the SQL INSERT
statement to be executed.
After entering the appropriate data for all fields in the Insert DB Insert window,
the following markup is generated in our page:
<sql:update var="insertedRows" dataSource="jdbc/sample">
INSERT INTO customer (customer_id, name,
discount_code,zip) values
(((select max(customer_id) from customer) + 1),
'Ensode Technology, LLC', 'H', '22030')
</sql:update>
The attributes and the body of the generated <sql:update> tag get populated
from the data we entered in the Insert DB Insert window.
We can add a DB Report item from the NetBeans palette, so that we can see the
value we inserted into the database. After doing so, the body of our page looks
like this:
<body>
<h2>Hello World!</h2>
<sql:update var="insertedRows" dataSource="jdbc/sample">
INSERT INTO customer (customer_id, name,
discount_code, zip) values
(((select max(customer_id) from customer) + 1),
'Ensode Technology, LLC', 'H', '22030')
</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" items="${result.columnNames}">
<th><c:out value="${columnName}"/></th>
</c:forEach>
</tr>
 
Search WWH ::




Custom Search