Oracle Web RowSet – Part2

3 min read

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.

The second row values are retrieved from the Web RowSet:

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

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>
Packt

Share
Published by
Packt

Recent Posts

Top life hacks for prepping for your IT certification exam

I remember deciding to pursue my first IT certification, the CompTIA A+. I had signed…

3 years ago

Learn Transformers for Natural Language Processing with Denis Rothman

Key takeaways The transformer architecture has proved to be revolutionary in outperforming the classical RNN…

3 years ago

Learning Essential Linux Commands for Navigating the Shell Effectively

Once we learn how to deploy an Ubuntu server, how to manage users, and how…

3 years ago

Clean Coding in Python with Mariano Anaya

Key-takeaways:   Clean code isn’t just a nice thing to have or a luxury in software projects; it's a necessity. If we…

3 years ago

Exploring Forms in Angular – types, benefits and differences   

While developing a web application, or setting dynamic pages and meta tags we need to deal with…

3 years ago

Gain Practical Expertise with the Latest Edition of Software Architecture with C# 9 and .NET 5

Software architecture is one of the most discussed topics in the software industry today, and…

3 years ago