473,387 Members | 1,515 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Error in CachedRowSet?

Hi All,

I tried the following code to run in jsp using Tomcat 4, the following code took from web.

Code:

<%@ page import="sun.jdbc.rowset.CachedRowSet" %>
<HTML>
<HEAD>
<jsp:useBean id="Contacts" class="sun.jdbc.rowset.CachedRowSet" scope="session">
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// initialize our CachedRowSet bean
Contacts.setUsername("sa");
Contacts.setPassword("");
Contacts.setUrl("jdbc:odbc:VFS");
Contacts.setCommand("SELECT name, telephone from Contacts");
Contacts.execute();
Contacts.first();
%>
</jsp:useBean>

<%
// get the servlet request object
javax.servlet.ServletRequest req = pageContext.getRequest();

// process updates
boolean updateRow = false;
String contactName = Contacts.getString(1);
String newValue = req.getParameter("ContactName");
if (( newValue != null) && (!newValue.equals( contactName ))) {
Contacts.updateString( 1,req.getParameter("ContactName"));
updateRow = true;
}
String contactPhone = Contacts.getString(2);
newValue = req.getParameter("ContactPhone");
if (( newValue != null) && (!newValue.equals(contactPhone))) {
Contacts.updateString( 2,req.getParameter("ContactPhone"));
updateRow = true;
}
if (updateRow) Contacts.updateRow();

// process navigation commands
if ( req.getParameter("next") != null ) {
if (! Contacts.next() ) Contacts.last();
} else if ( req.getParameter("prev") != null) {
if (! Contacts.previous()) Contacts.first();
} else if ( req.getParameter("save") != null) {
Contacts.acceptChanges();
} else if ( req.getParameter("insert") != null) {
Contacts.moveToInsertRow();
Contacts.updateString(1, "");
Contacts.updateString(2, "");
Contacts.insertRow();
Contacts.moveToCurrentRow();
Contacts.next();
} else if ( req.getParameter("delete") != null) {
Contacts.deleteRow();
if (!Contacts.next()) Contacts.last();
}
%>
<STYLE>
BODY { font-style: verdana }
</STYLE>
<TITLE>
CachedRowSetExample
</TITLE>
</HEAD>
<BODY BGCOLOR='lightgrey'>
<H2>Contacts</H2>
<FORM METHOD="POST">
<TABLE BORDER='0'>
<TR><TD>Name:</TD><TD>Telephone number:</TD></TR>
<TR>
<TD><INPUT TYPE='text'
NAME="ContactName"
VALUE='<%=Contacts.getString(1)%>' /></TD>
<TD><INPUT TYPE="text"
NAME="ContactPhone"
VALUE='<%=Contacts.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.getRow()%> of <%=Contacts.size()%>
</FORM>
</BODY>
</HTML>


When i run this program the following error occurred:

org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.

C:\Program Files\Apache Tomcat 4.0\work\localhost\web\CachedRowSetExample$jsp.jav a: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
Jul 4 '07 #1
2 2047
praveen2gupta
201 100+
Hi

you are using Java Beans in the program. In case of Beans the java class must be in the WEB-INF/classes folder. Inside this folder you can apply packages if applicable. So do following in the program

1. make the classes folder inside WEB-INF, copy your class file inside the folder.

2. your cuurrent Java Bean is this one.
<jsp:useBean id="Contacts" class="sun.jdbc.rowset.CachedRowSet" scope="session">

Here in the classes this might be a package which is being implimented by the source where you have taken this code change it as follows.

<jsp:useBean id="Contacts" class="CachedRowSet" scope="session">

CachedRowSet is the class name in the folder clases.

Try this and let me know the result
Jul 6 '07 #2
Hi

you are using Java Beans in the program. In case of Beans the java class must be in the WEB-INF/classes folder. Inside this folder you can apply packages if applicable. So do following in the program

1. make the classes folder inside WEB-INF, copy your class file inside the folder.

2. your cuurrent Java Bean is this one.
<jsp:useBean id="Contacts" class="sun.jdbc.rowset.CachedRowSet" scope="session">

Here in the classes this might be a package which is being implimented by the source where you have taken this code change it as follows.

<jsp:useBean id="Contacts" class="CachedRowSet" scope="session">

CachedRowSet is the class name in the folder clases.

Try this and let me know the result



Hi praveengupta,

Thanks for reply...

I have already tried your suggestion before u replied to this post,
but it also throws the following error:

Generated servlet error:
C:\Program Files\Apache Tomcat 4.0\work\localhost\web\CachedRowSetExample$jsp.jav a:60: Class org.apache.jsp.CachedRowSet not found.
CachedRowSet Contacts = null;
^


An error occurred at line: 3 in the jsp file: /CachedRowSetExample.jsp

Generated servlet error:
C:\Program Files\Apache Tomcat 4.0\work\localhost\web\CachedRowSetExample$jsp.jav a:63: Class org.apache.jsp.CachedRowSet not found.
Contacts= (CachedRowSet)
^


An error occurred at line: 3 in the jsp file: /CachedRowSetExample.jsp

Generated servlet error:
C:\Program Files\Apache Tomcat 4.0\work\localhost\web\CachedRowSetExample$jsp.jav a:68: Class org.apache.jsp.CachedRowSet not found.
Contacts = (CachedRowSet) java.beans.Beans.instantiate(this.getClass().getCl assLoader(), "CachedRowSet");
^
3 errors, 1 warning

Why this error displayed when i run this program?

Is there any other way?


Thanks & Regards,


V. Prasath
Jul 7 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Jeremy | last post by:
Hi, can anybody tell me where/how to get Sun's implementation of CachedRowSet?? I've found (old-ish) articles saying it's available as rowset.jar from the Early Access part of the developer...
2
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two...
13
by: deko | last post by:
I use this convention frequently: Exit_Here: Exit Sub HandleErr: Select Case Err.Number Case 3163 Resume Next Case 3376 Resume Next
7
by: p | last post by:
WE had a Crystal 8 WebApp using vs 2002 which we upgraded to VS2003. I also have Crystal 9 pro on my development machine. The web app runs fine on my dev machine but am having problems deploying....
1
by: prasath03 | last post by:
Dear all, I need a sample coding about CachedRowSet using in jsp without bean class. That code displays 10 records per page from the database when i click the Previous and Next button or link. ...
5
by: prasath03 | last post by:
Hi All, I tried CachedRowSet and it is working in my java class. crs.setCommand("SELECT * from test"); System.out.println("Connection establishing ......"); crs.execute();...
1
by: prasath03 | last post by:
I'm new to JSP, and am trying this sample code for instantiating a bean for use in a disconnected ResultSet, i placed the rowset.jar under WEB-INF/lib directory but i get the following error: ...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.