当前位置: 技术问答>java相关
求教:collection的问题,解决问题立刻结帐
来源: 互联网 发布时间:2015-09-07
本文导语: public java.util.Collection ejbFindByAll() throws FinderException { ArrayList userList = new ArrayList(); GroupInfoBean groupInfo; try { con = DBConnection.getConnection(); stmt = con.prepareStatement("SELECT * FROM...
public java.util.Collection ejbFindByAll() throws FinderException {
ArrayList userList = new ArrayList();
GroupInfoBean groupInfo;
try {
con = DBConnection.getConnection();
stmt = con.prepareStatement("SELECT * FROM USERGROUP");
ResultSet rs = stmt.executeQuery();
while(rs.next()) {
groupInfo = new GroupInfoBean();
groupInfo.setGroupID(rs.getString(1));
groupInfo.setGroupPermission(rs.getString(2));
groupInfo.setGroupDescription(rs.getString(3));
userList.add(groupInfo);
}
……
}
在entitybeqan中的返回值collection
在client端引用
java.util.Collection collection = client.getHome().findByAll();
java.util.Iterator userList = collection.iterator();
while(userList.hasNext())
{
groupInfo = (GroupInfoBean)userList.next();
}
}catch(Exception e){e.printStackTrace();
}
但是系统却抛出java.lang.ClassCastException
怎么回事,解决问题立刻结帐
ArrayList userList = new ArrayList();
GroupInfoBean groupInfo;
try {
con = DBConnection.getConnection();
stmt = con.prepareStatement("SELECT * FROM USERGROUP");
ResultSet rs = stmt.executeQuery();
while(rs.next()) {
groupInfo = new GroupInfoBean();
groupInfo.setGroupID(rs.getString(1));
groupInfo.setGroupPermission(rs.getString(2));
groupInfo.setGroupDescription(rs.getString(3));
userList.add(groupInfo);
}
……
}
在entitybeqan中的返回值collection
在client端引用
java.util.Collection collection = client.getHome().findByAll();
java.util.Iterator userList = collection.iterator();
while(userList.hasNext())
{
groupInfo = (GroupInfoBean)userList.next();
}
}catch(Exception e){e.printStackTrace();
}
但是系统却抛出java.lang.ClassCastException
怎么回事,解决问题立刻结帐
|
你还可以搜索GroupinfoBean.class,看看能找到几个