Error in CachedRowSet?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • prasath03
    New Member
    • Jun 2007
    • 30

    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.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
  • praveen2gupta
    New Member
    • May 2007
    • 200

    #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.CachedR owSet" 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="CachedRo wSet" scope="session" >

    CachedRowSet is the class name in the folder clases.

    Try this and let me know the result

    Comment

    • prasath03
      New Member
      • Jun 2007
      • 30

      #3
      Originally posted by praveen2gupta
      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.CachedR owSet" 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="CachedRo wSet" 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\localh ost\web\CachedR owSetExample$js p.java:60: Class org.apache.jsp. CachedRowSet not found.
      CachedRowSet Contacts = null;
      ^


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

      Generated servlet error:
      C:\Program Files\Apache Tomcat 4.0\work\localh ost\web\CachedR owSetExample$js p.java:63: Class org.apache.jsp. CachedRowSet not found.
      Contacts= (CachedRowSet)
      ^


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

      Generated servlet error:
      C:\Program Files\Apache Tomcat 4.0\work\localh ost\web\CachedR owSetExample$js p.java:68: Class org.apache.jsp. CachedRowSet not found.
      Contacts = (CachedRowSet) java.beans.Bean s.instantiate(t his.getClass(). getClassLoader( ), "CachedRowSet") ;
      ^
      3 errors, 1 warning

      Why this error displayed when i run this program?

      Is there any other way?


      Thanks & Regards,


      V. Prasath

      Comment

      Working...