Error for java.lang.InstantiationException in using CachedRowSet

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

    Error for java.lang.InstantiationException in using CachedRowSet

    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:

    javax.servlet.S ervletException : interface javax.sql.rowse t.CachedRowSet : java.lang.Insta ntiationExcepti on: javax.sql.rowse t.CachedRowSet

    and

    root cause

    java.lang.Insta ntiationExcepti on: interface javax.sql.rowse t.CachedRowSet : java.lang.Insta ntiationExcepti on: javax.sql.rowse t.CachedRowSet


    Why won't it instantiate?

    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(" org.gjt.mm.mysq l.Driver").newI nstance();
    // initialize our CachedRowSet bean
    Contacts.setUse rname("webuser" );
    Contacts.setPas sword("pwd");
    Contacts.setUrl ("jdbc:mysql ://localhost:3306/person");
    // some drivers require this
    Contacts.setTab leName("contact s");
    Contacts.setCom mand("SELECT name, telephone from contacts");
    Contacts.execut e();
    Contacts.first( );
    %>
    </jsp:useBean>


    thanks in advance........ .

    Regards,

    V. Prasath
    Last edited by prasath03; Jul 31 '07, 07:22 AM. Reason: typed title wrong
  • madhoriya22
    Contributor
    • Jul 2007
    • 251

    #2
    Originally posted by prasath03
    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:

    javax.servlet.S ervletException : interface javax.sql.rowse t.CachedRowSet : java.lang.Insta ntiationExcepti on: javax.sql.rowse t.CachedRowSet

    and

    root cause

    java.lang.Insta ntiationExcepti on: interface javax.sql.rowse t.CachedRowSet : java.lang.Insta ntiationExcepti on: javax.sql.rowse t.CachedRowSet


    Why won't it instantiate?

    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(" org.gjt.mm.mysq l.Driver").newI nstance();
    // initialize our CachedRowSet bean
    Contacts.setUse rname("webuser" );
    Contacts.setPas sword("pwd");
    Contacts.setUrl ("jdbc:mysql ://localhost:3306/person");
    // some drivers require this
    Contacts.setTab leName("contact s");
    Contacts.setCom mand("SELECT name, telephone from contacts");
    Contacts.execut e();
    Contacts.first( );
    %>
    </jsp:useBean>


    thanks in advance........ .

    Regards,

    V. Prasath
    Hi,
    This exception is thrown when u r trying to create a instance of a class using new operator, but it not a class instead it is interface or abstract class.
    I think u hav done the same mistake.......C achedRowSet is a interface..and u trying to create instance of that...check it again.
    thanks and regards,
    madoriya

    Comment

    Working...