一个简单的EJB实例.用DB2连接.JSP页面.很好用.供大家学习
源代码在线查看: ejscmplocationhomebean_176caeeb.java
package salesdb; import com.ibm.ejs.container.*; /** * EJSCMPLocationHomeBean_176caeeb */ public class EJSCMPLocationHomeBean_176caeeb extends EJSHome { /** * EJSCMPLocationHomeBean_176caeeb */ public EJSCMPLocationHomeBean_176caeeb() throws java.rmi.RemoteException { super(); } /** * findByPrimaryKey_Local */ public salesdb.LocationLocal findByPrimaryKey_Local(salesdb.LocationKey primaryKey) throws javax.ejb.FinderException, java.rmi.RemoteException { return (salesdb.LocationLocal)super.activateBean_Local(primaryKey); } /** * create_Local */ public salesdb.LocationLocal create_Local(java.lang.String zipcode, java.lang.String city, java.lang.String state, java.lang.String areacode) throws javax.ejb.CreateException, java.rmi.RemoteException { BeanO beanO = null; salesdb.LocationLocal result = null; boolean createFailed = false; boolean preCreateFlag = false; try { beanO = super.createBeanO(); salesdb.LocationBean bean = (salesdb.LocationBean) beanO.getEnterpriseBean(); preCreateFlag = super.preEjbCreate(beanO); bean.ejbCreate(zipcode, city, state, areacode); Object ejsKey = keyFromBean(bean); result = (salesdb.LocationLocal) super.postCreate_Local(beanO, ejsKey, true); bean.ejbPostCreate(zipcode, city, state, areacode); super.afterPostCreate(beanO, ejsKey); } catch (javax.ejb.CreateException ex) { createFailed = true; throw ex; } catch (java.rmi.RemoteException ex) { createFailed = true; throw ex; } catch (Throwable ex) { createFailed = true; throw new CreateFailureException(ex); } finally { if(preCreateFlag && !createFailed) super.afterPostCreateCompletion(beanO); if (createFailed) { super.createFailure(beanO); } } return result; } /** * create_Local */ public salesdb.LocationLocal create_Local(java.lang.String zipcode) throws javax.ejb.CreateException, java.rmi.RemoteException { BeanO beanO = null; salesdb.LocationLocal result = null; boolean createFailed = false; boolean preCreateFlag = false; try { beanO = super.createBeanO(); salesdb.LocationBean bean = (salesdb.LocationBean) beanO.getEnterpriseBean(); preCreateFlag = super.preEjbCreate(beanO); bean.ejbCreate(zipcode); Object ejsKey = keyFromBean(bean); result = (salesdb.LocationLocal) super.postCreate_Local(beanO, ejsKey, true); bean.ejbPostCreate(zipcode); super.afterPostCreate(beanO, ejsKey); } catch (javax.ejb.CreateException ex) { createFailed = true; throw ex; } catch (java.rmi.RemoteException ex) { createFailed = true; throw ex; } catch (Throwable ex) { createFailed = true; throw new CreateFailureException(ex); } finally { if(preCreateFlag && !createFailed) super.afterPostCreateCompletion(beanO); if (createFailed) { super.createFailure(beanO); } } return result; } /** * findLocationfkByLocationfkPurchaseInverseKey_Local */ public salesdb.LocationLocal findLocationfkByLocationfkPurchaseInverseKey_Local(salesdb.PurchaseKey key) throws javax.ejb.FinderException, java.rmi.RemoteException { salesdb.LocationLocal result = null; EntityBeanO beanO = null; salesdb.LocationKey pKey = null; try { beanO = super.getFinderEntityBeanO(); salesdb.ConcreteLocation_176caeeb bean = (salesdb.ConcreteLocation_176caeeb) beanO.getEnterpriseBean(); pKey = bean.ejbFindLocationfkByLocationfkPurchaseInverseKey_Local(key); result = (salesdb.LocationLocal)activateBean_Local(pKey); super.releaseFinderEntityBeanO(beanO); beanO = null; } catch (javax.ejb.FinderException finderEx) { super.releaseFinderEntityBeanO(beanO); beanO = null; throw finderEx; } finally { if (beanO != null ) super.discardFinderEntityBeanO(beanO); } return result; } /** * findByPrimaryKeyForCMR_Local */ public salesdb.LocationLocal findByPrimaryKeyForCMR_Local(salesdb.LocationKey key) throws javax.ejb.FinderException, java.rmi.RemoteException { return (salesdb.LocationLocal)super.activateBean_Local(key); } /** * keyFromBean */ public Object keyFromBean(javax.ejb.EntityBean generalEJB) { salesdb.ConcreteLocation_176caeeb tmpEJB = (salesdb.ConcreteLocation_176caeeb) generalEJB; salesdb.LocationKey keyClass = new salesdb.LocationKey(); keyClass.zipcode = tmpEJB.getZipcode(); return keyClass; } /** * keyFromFields */ public salesdb.LocationKey keyFromFields(java.lang.String f0) { salesdb.LocationKey keyClass = new salesdb.LocationKey(); keyClass.zipcode = f0; return keyClass; } }