Hi All,
I tried the following code to run in jsp using Tomcat 4, the following code took from web.
Code:
<%@ page import="sun.jdb c.rowset.Cached RowSet" %>
<HTML>
<HEAD>
<jsp:useBean id="Contacts" class="sun.jdbc .rowset.CachedR owSet" scope="session" >
<%
Class.forName(" sun.jdbc.odbc.J dbcOdbcDriver") ;
// initialize our CachedRowSet bean
Contacts.setUse rname("sa");
Contacts.setPas sword("");
Contacts.setUrl ("jdbc:odbc:VFS ");
Contacts.setCom mand("SELECT name, telephone from Contacts");
Contacts.execut e();
Contacts.first( );
%>
</jsp:useBean>
<%
// get the servlet request object
javax.servlet.S ervletRequest req = pageContext.get Request();
// process updates
boolean updateRow = false;
String contactName = Contacts.getStr ing(1);
String newValue = req.getParamete r("ContactName" );
if (( newValue != null) && (!newValue.equa ls( contactName ))) {
Contacts.update String( 1,req.getParame ter("ContactNam e"));
updateRow = true;
}
String contactPhone = Contacts.getStr ing(2);
newValue = req.getParamete r("ContactPhone ");
if (( newValue != null) && (!newValue.equa ls(contactPhone ))) {
Contacts.update String( 2,req.getParame ter("ContactPho ne"));
updateRow = true;
}
if (updateRow) Contacts.update Row();
// process navigation commands
if ( req.getParamete r("next") != null ) {
if (! Contacts.next() ) Contacts.last() ;
} else if ( req.getParamete r("prev") != null) {
if (! Contacts.previo us()) Contacts.first( );
} else if ( req.getParamete r("save") != null) {
Contacts.accept Changes();
} else if ( req.getParamete r("insert") != null) {
Contacts.moveTo InsertRow();
Contacts.update String(1, "");
Contacts.update String(2, "");
Contacts.insert Row();
Contacts.moveTo CurrentRow();
Contacts.next() ;
} else if ( req.getParamete r("delete") != null) {
Contacts.delete Row();
if (!Contacts.next ()) Contacts.last() ;
}
%>
<STYLE>
BODY { font-style: verdana }
</STYLE>
<TITLE>
CachedRowSetExa mple
</TITLE>
</HEAD>
<BODY BGCOLOR='lightg rey'>
<H2>Contacts</H2>
<FORM METHOD="POST">
<TABLE BORDER='0'>
<TR><TD>Name: </TD><TD>Telephon e number:</TD></TR>
<TR>
<TD><INPUT TYPE='text'
NAME="ContactNa me"
VALUE='<%=Conta cts.getString(1 )%>' /></TD>
<TD><INPUT TYPE="text"
NAME="ContactPh one"
VALUE='<%=Conta cts.getString(2 )%>' /></TD>
</TABLE>
<INPUT TYPE="submit" NAME="prev" VALUE=" < "/>
<INPUT TYPE="submit" NAME="next" VALUE=" > "/>
<INPUT TYPE="submit" NAME="insert" VALUE="Insert"/>
<INPUT TYPE="submit" NAME="delete" VALUE="Delete"/>
<INPUT TYPE="submit" NAME="save" VALUE="Save"/>
Record <%=Contacts.get Row()%> of <%=Contacts.siz e()%>
</FORM>
</BODY>
</HTML>
When i run this program the following error occurred:
org.apache.jasp er.JasperExcept ion: Unable to compile class for JSPNote: sun.tools.javac .Main has been deprecated.
C:\Program Files\Apache Tomcat 4.0\work\localh ost\web\CachedR owSetExample$js p.java:3: Class sun.jdbc.rowset .CachedRowSet not found in import.
import sun.jdbc.rowset .CachedRowSet;
^
I added the rowset.jar file under WEB-INF/lib.
Where did i wrong in my code?
If anybody know the answer kindly post ur suggestion.
How to add the rowset.jar file in my WEB-INF/lib and how to call the class file in my application from rowset.jar? Is there any procedure to add the rowset.jar file in my application?
Thanks and Regards,
V. Prasath
I tried the following code to run in jsp using Tomcat 4, the following code took from web.
Code:
<%@ page import="sun.jdb c.rowset.Cached RowSet" %>
<HTML>
<HEAD>
<jsp:useBean id="Contacts" class="sun.jdbc .rowset.CachedR owSet" scope="session" >
<%
Class.forName(" sun.jdbc.odbc.J dbcOdbcDriver") ;
// initialize our CachedRowSet bean
Contacts.setUse rname("sa");
Contacts.setPas sword("");
Contacts.setUrl ("jdbc:odbc:VFS ");
Contacts.setCom mand("SELECT name, telephone from Contacts");
Contacts.execut e();
Contacts.first( );
%>
</jsp:useBean>
<%
// get the servlet request object
javax.servlet.S ervletRequest req = pageContext.get Request();
// process updates
boolean updateRow = false;
String contactName = Contacts.getStr ing(1);
String newValue = req.getParamete r("ContactName" );
if (( newValue != null) && (!newValue.equa ls( contactName ))) {
Contacts.update String( 1,req.getParame ter("ContactNam e"));
updateRow = true;
}
String contactPhone = Contacts.getStr ing(2);
newValue = req.getParamete r("ContactPhone ");
if (( newValue != null) && (!newValue.equa ls(contactPhone ))) {
Contacts.update String( 2,req.getParame ter("ContactPho ne"));
updateRow = true;
}
if (updateRow) Contacts.update Row();
// process navigation commands
if ( req.getParamete r("next") != null ) {
if (! Contacts.next() ) Contacts.last() ;
} else if ( req.getParamete r("prev") != null) {
if (! Contacts.previo us()) Contacts.first( );
} else if ( req.getParamete r("save") != null) {
Contacts.accept Changes();
} else if ( req.getParamete r("insert") != null) {
Contacts.moveTo InsertRow();
Contacts.update String(1, "");
Contacts.update String(2, "");
Contacts.insert Row();
Contacts.moveTo CurrentRow();
Contacts.next() ;
} else if ( req.getParamete r("delete") != null) {
Contacts.delete Row();
if (!Contacts.next ()) Contacts.last() ;
}
%>
<STYLE>
BODY { font-style: verdana }
</STYLE>
<TITLE>
CachedRowSetExa mple
</TITLE>
</HEAD>
<BODY BGCOLOR='lightg rey'>
<H2>Contacts</H2>
<FORM METHOD="POST">
<TABLE BORDER='0'>
<TR><TD>Name: </TD><TD>Telephon e number:</TD></TR>
<TR>
<TD><INPUT TYPE='text'
NAME="ContactNa me"
VALUE='<%=Conta cts.getString(1 )%>' /></TD>
<TD><INPUT TYPE="text"
NAME="ContactPh one"
VALUE='<%=Conta cts.getString(2 )%>' /></TD>
</TABLE>
<INPUT TYPE="submit" NAME="prev" VALUE=" < "/>
<INPUT TYPE="submit" NAME="next" VALUE=" > "/>
<INPUT TYPE="submit" NAME="insert" VALUE="Insert"/>
<INPUT TYPE="submit" NAME="delete" VALUE="Delete"/>
<INPUT TYPE="submit" NAME="save" VALUE="Save"/>
Record <%=Contacts.get Row()%> of <%=Contacts.siz e()%>
</FORM>
</BODY>
</HTML>
When i run this program the following error occurred:
org.apache.jasp er.JasperExcept ion: Unable to compile class for JSPNote: sun.tools.javac .Main has been deprecated.
C:\Program Files\Apache Tomcat 4.0\work\localh ost\web\CachedR owSetExample$js p.java:3: Class sun.jdbc.rowset .CachedRowSet not found in import.
import sun.jdbc.rowset .CachedRowSet;
^
I added the rowset.jar file under WEB-INF/lib.
Where did i wrong in my code?
If anybody know the answer kindly post ur suggestion.
How to add the rowset.jar file in my WEB-INF/lib and how to call the class file in my application from rowset.jar? Is there any procedure to add the rowset.jar file in my application?
Thanks and Regards,
V. Prasath
Comment