hi...
i have made bmp bean when i try to run the following method(ejbFindByFirstName()) from the client side it will give me the following error.here i am sending u client code ,menthod and a class which i am using
------------------
java.lang.ClassCastException: EmpEntityBean_xzbwyf_EOImpl_WLStub
at ConnectClient.go(ConnectClient.java:50)
at ConnectClient.main(ConnectClient.java:13)
---------------
public Collection ejbFindByFirstName(
String lFirstName) throws FinderException
{
PreparedStatement pstmt = null;
Connection conn = null;
ResultSet result = null;
ReturnVector rv=new ReturnVector();
try
{
conn = this.getConnection();
System.out.println("ejbFindByFirstName(" + lFirstName + ") called");
pstmt = conn.prepareStatement("SELECT EMPID,EMPFIRSTNAME,EMPLASTNAME FROM EMPDATA WHERE EMPFIRSTNAME = ?");
pstmt.setString(1, lFirstName);
result = pstmt.executeQuery();
Vector keys=new Vector();
System.out.println("Before while in findbyfirst name");
while (result.next())
{
System.out.println("in while findbyfirst name");
System.out.println(result.getInt("EMPID"));
System.out.println(result.getString("EMPFIRSTNAME"));
System.out.println(result.getString("EMPLASTNAME"));
rv.EmpId=result.getInt("EMPID");
rv.FirstName=result.getString("EMPFIRSTNAME");
rv.LastName=result.getString("EMPLASTNAME");
keys.addElement(rv);
}
System.out.println("After while in findbyfirst name");
return keys;
}
catch (Exception e)
{
throw new FinderException(e.toString());
}
finally
{
try { if (pstmt != null) pstmt.close(); }
catch (Exception e) {}
try { if (conn != null) conn.close(); }
catch (Exception e) {}
}
}
----------------------
import java.io.Serializable;
public class ReturnVector implements java.io.Serializable
{
int EmpId;
String FirstName;
String LastName;
}
---------------------
client code
--------------------------
Collection c = home.findByFirstName("hello");
Vector v=new Vector(c);;
ReturnVector rv=(ReturnVector)v.firstElement(); // error is here
System.out.println(rv.EmpId);
System.out.println(rv.FirstName);
System.out.println(rv.LastName);
-------------------------
my ejbFindByFirstName() method returning a vector which contain the object of class ReturnVector. i used this class be becoz i want to return multiple values form method.plz help me out how can i solve this problem. i also want to know that if my method returning multiple records how i can i get from the client side...
in my above problem in find method returning vector contain object of RetunVector class. if my returning vector contain string or int then from the client if i access then there is not any error but it will print following
EmpEntityBean_xzbwyf_EOImpl_WLStub
i didnot understand what this is all about
plz help me to solve this problem.....
regards
amit grover