Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds

Oracle Web RowSet - Part2

Save for later
  • 4 min read
  • 27 Oct 2009

article-image

Reading a Row

Next, we will read a row from the OracleWebRowSet object. Click on Modify Web RowSet link in the CreateRow.jsp. In the ModifyWebRowSet JSP click on the Read Row link. The ReadRow.jsp JSP is displayed. In the ReadRow JSP specify the Database Row to Read and click on Apply.

oracle-web-rowset-part2-img-0

The second row values are retrieved from the Web RowSet:

oracle-web-rowset-part2-img-1

In the ReadRow JSP the readRow() method of the WebRowSetQuery.java application is invoked. TheWebRowSetQuery object is retrieved from the session object.

Unlock access to the largest independent learning library in Tech for FREE!
Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
Renews at AU $19.99/month. Cancel anytime
WebRowSetQuery query=( webrowset.WebRowSetQuery)
session.getAttribute("query");

The String[] values returned by the readRow() method are added to theReadRow JSP fields. In the readRow() method theOracleWebRowSet object cursor is moved to the row to be read.

webRowSet.absolute(rowRead);

Retrieve the row values with the getString() method and add to String[]. Return the String[] object.

String[] resultSet=new String[5];
resultSet[0]=webRowSet.getString(1);
resultSet[1]=webRowSet.getString(2);
resultSet[2]=webRowSet.getString(3);
resultSet[3]=webRowSet.getString(4);
resultSet[4]=webRowSet.getString(5);
return resultSet;

ReadRow.jsp JSP is listed as follows:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ page session="true"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<title>Read Row with Web RowSet</title>
</head>
<body>
<form><h3>Read Row with Web RowSet</h3>
<table>
<tr>
<td><a href="ModifyWebRowSet.jsp">Modify Web RowSet
Page</a></td>
</tr>
</table>
</form>
<%
webrowset.WebRowSetQuery query=null;
query=( webrowset.WebRowSetQuery)
session.getAttribute("query");
String rowRead=request.getParameter("rowRead");
String journalUpdate=request.getParameter("journalUpdate");
String publisherUpdate=request.getParameter("publisherUpdate");
String editionUpdate=request.getParameter("editionUpdate");
String titleUpdate=request.getParameter("titleUpdate");
String authorUpdate=request.getParameter("authorUpdate");
if((rowRead!=null))
{
int row_Read=Integer.parseInt(rowRead);
String[] resultSet=query.readRow(row_Read);
journalUpdate=resultSet[0];
publisherUpdate=resultSet[1];
editionUpdate=resultSet[2];
titleUpdate=resultSet[3];
authorUpdate=resultSet[4];
}
%>
<form name="query" action="ReadRow.jsp" method="post">
<table>
<tr>
<td>Database Row to Read:</td>
</tr>
<tr>
<td>
<input name="rowRead" type="text" size="25"
maxlength="50"/>
</td>
</tr>
<tr>
<td>Journal:</td>
</tr>
<tr>
<td>
<input name="journalUpdate" value='<%=journalUpdate%>'
type="text" size="50" maxlength="250"/>
</td>
</tr>
<tr>
<td>Publisher:</td>
</tr>
<tr>
<td>
<input name="publisherUpdate"
value='<%=publisherUpdate%>' type="text" size="50"
maxlength="250"/>
</td>
</tr>
<tr>
<td>Edition:</td>
</tr>
<tr>
<td>
<input name="editionUpdate" value='<%=editionUpdate%>'
type="text" size="50" maxlength="250"/>
</td>
</tr>
<tr>
<td>Title:</td>
</tr>
<tr>
<td>
<input name="titleUpdate" value='<%=titleUpdate%>'
type="text" size="50" maxlength="250"/>
</td>
</tr>
<tr>
<td>Author:</td>
</tr>
<tr>
<td>
<input name="authorUpdate" value='<%=authorUpdate%>'
type="text" size="50" maxlength="250"/>
</td>
</tr><tr>
<td>
<input class="Submit" type="submit" value="Apply"/>
</td>
</tr>
</table>
</form>
</body>
</html>