Error in BMP findAll() method null error
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Karthikeyan_Radhakrishna
Posted On:   Wednesday, June 4, 2003 03:25 AM

I wrote a BMP findAll() method, my table has two fields id, name. In my client program I receive the id values correctly but I receive a null value for the name. Can any one plz explain me public Collection ejbFindAll() throws FinderException { Vector v = new Vector(); String allSt = "select id,name from dummycheck"; try { PreparedStatement ps = conn.prepareStatement(allSt); ResultSet rs = ps.executeQuery(); while (rs.next()) { Long id1 = new Long(rs.getLong(1)); String name = rs.getString(2); v.add(id1); } } catch(SQLException ex) {} return v; } Client program:    More>>

I wrote a BMP findAll() method, my table has two fields id, name. In my client program I receive the id values correctly but I receive a null value for the name.


Can any one plz explain me




			
public Collection ejbFindAll() throws FinderException
{
Vector v = new Vector();
String allSt = "select id,name from dummycheck";
try
{
PreparedStatement ps = conn.prepareStatement(allSt);
ResultSet rs = ps.executeQuery();
while (rs.next())
{
Long id1 = new Long(rs.getLong(1));
String name = rs.getString(2);
v.add(id1);
}
}
catch(SQLException ex)
{}
return v;
}


Client program:
			
Collection coll = cmpejbHome.findAll();
Iterator iter = coll.iterator();
while (iter.hasNext())
{
cmpejb = (CMPEJB)iter.next();
System.out.println("id = " + cmpejb.getId());
System.out.println("name = " + cmpejb.getName());
System.out.println();
}
   <<Less

Re: Error in BMP findAll() method null error

Posted By:   Alexey_Ryndin  
Posted On:   Wednesday, June 4, 2003 04:30 AM

The real point where your bean is loaded is ejbLoad() method, so it is the place for you to check the reason for null value for the name field. It is no need to load name from table in ejbFindAll() method listed.

Re: Error in BMP findAll() method null error

Posted By:   AlessandroA_Garbagnati  
Posted On:   Wednesday, June 4, 2003 04:18 AM

Hi,

Maybe there is an error, but since you are ignoring it (catch(SQLException ex) {}) you cannot verify that.
About | Sitemap | Contact