一个简单的EJB实例.用DB2连接.JSP页面.很好用.供大家学习
源代码在线查看: itembean.java
package salesdb;
/**
* Bean implementation class for Enterprise Bean: Item
*/
public abstract class ItemBean implements javax.ejb.EntityBean {
private javax.ejb.EntityContext myEntityCtx;
/**
* setEntityContext
*/
public void setEntityContext(javax.ejb.EntityContext ctx) {
myEntityCtx = ctx;
}
/**
* getEntityContext
*/
public javax.ejb.EntityContext getEntityContext() {
return myEntityCtx;
}
/**
* unsetEntityContext
*/
public void unsetEntityContext() {
myEntityCtx = null;
}
/**
* ejbCreate
*/
public salesdb.ItemKey ejbCreate(java.lang.Long itemid)
throws javax.ejb.CreateException {
setItemid(itemid);
return null;
}
/**
* ejbPostCreate
*/
public void ejbPostCreate(java.lang.Long itemid)
throws javax.ejb.CreateException {
}
/**
* ejbActivate
*/
public void ejbActivate() {
}
/**
* ejbLoad
*/
public void ejbLoad() {
}
/**
* ejbPassivate
*/
public void ejbPassivate() {
}
/**
* ejbRemove
*/
public void ejbRemove() throws javax.ejb.RemoveException {
}
/**
* ejbStore
*/
public void ejbStore() {
}
/**
* ejbCreate method for a CMP entity bean.
*/
public salesdb.ItemKey ejbCreate(
java.lang.Long itemid,
java.lang.String name)
throws javax.ejb.CreateException {
setItemid(itemid);
setName(name);
return null;
}
/**
* ejbPostCreate
*/
public void ejbPostCreate(java.lang.Long itemid, java.lang.String name)
throws javax.ejb.CreateException {
}
/**
* Get accessor for persistent attribute: itemid
*/
public abstract java.lang.Long getItemid();
/**
* Set accessor for persistent attribute: itemid
*/
public abstract void setItemid(java.lang.Long newItemid);
/**
* Get accessor for persistent attribute: name
*/
public abstract java.lang.String getName();
/**
* Set accessor for persistent attribute: name
*/
public abstract void setName(java.lang.String newName);
}