By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,780 Members | 1,549 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,780 IT Pros & Developers. It's quick & easy.

Error for java.lang.InstantiationException in using CachedRowSet

P: 30
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.ServletException: interface javax.sql.rowset.CachedRowSet : java.lang.InstantiationException: javax.sql.rowset.CachedRowSet

and

root cause

java.lang.InstantiationException: interface javax.sql.rowset.CachedRowSet : java.lang.InstantiationException: javax.sql.rowset.CachedRowSet


Why won't it instantiate?

Code:
<%@ page import="sun.jdbc.rowset.CachedRowSet" %>


<HTML>
<HEAD>
<jsp:useBean id="Contacts" class="sun.jdbc.rowset.CachedRowSet" scope="session">
<%
Class.forName("org.gjt.mm.mysql.Driver").newInstan ce();
// initialize our CachedRowSet bean
Contacts.setUsername("webuser");
Contacts.setPassword("pwd");
Contacts.setUrl("jdbc:mysql://localhost:3306/person");
// some drivers require this
Contacts.setTableName("contacts");
Contacts.setCommand("SELECT name, telephone from contacts");
Contacts.execute();
Contacts.first();
%>
</jsp:useBean>


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

Regards,

V. Prasath
Jul 31 '07 #1
Share this Question
Share on Google+
1 Reply


madhoriya22
100+
P: 252
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.ServletException: interface javax.sql.rowset.CachedRowSet : java.lang.InstantiationException: javax.sql.rowset.CachedRowSet

and

root cause

java.lang.InstantiationException: interface javax.sql.rowset.CachedRowSet : java.lang.InstantiationException: javax.sql.rowset.CachedRowSet


Why won't it instantiate?

Code:
<%@ page import="sun.jdbc.rowset.CachedRowSet" %>


<HTML>
<HEAD>
<jsp:useBean id="Contacts" class="sun.jdbc.rowset.CachedRowSet" scope="session">
<%
Class.forName("org.gjt.mm.mysql.Driver").newInstan ce();
// initialize our CachedRowSet bean
Contacts.setUsername("webuser");
Contacts.setPassword("pwd");
Contacts.setUrl("jdbc:mysql://localhost:3306/person");
// some drivers require this
Contacts.setTableName("contacts");
Contacts.setCommand("SELECT name, telephone from contacts");
Contacts.execute();
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.......CachedRowSet is a interface..and u trying to create instance of that...check it again.
thanks and regards,
madoriya
Jul 31 '07 #2

Post your reply

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