一个简单的EJB实例.用DB2连接.JSP页面.很好用.供大家学习
源代码在线查看: purchasebeanextractor_e813240d.java
package salesdb.websphere_deploy.DB2UDBNT_V8_1; /** * PurchaseBeanExtractor_e813240d */ public class PurchaseBeanExtractor_e813240d extends com.ibm.ws.ejbpersistence.dataaccess.AbstractEJBExtractor { /** * PurchaseBeanExtractor_e813240d */ public PurchaseBeanExtractor_e813240d() { int[] pkCols={1}; setPrimaryKeyColumns(pkCols); int[] dataCols={1,2,3,4}; setDataColumns(dataCols); } /** * extractData */ public com.ibm.ws.ejbpersistence.cache.DataCacheEntry extractData(com.ibm.ws.ejbpersistence.dataaccess.RawBeanData dataRow) throws com.ibm.ws.ejbpersistence.utilpm.ErrorProcessingResultCollectionRow, com.ibm.ws.ejbpersistence.utilpm.PersistenceManagerInternalError { int[] dataColumns = getDataColumns(); salesdb.websphere_deploy.DB2UDBNT_V8_1.PurchaseBeanCacheEntryImpl_e813240d entry= new salesdb.websphere_deploy.DB2UDBNT_V8_1.PurchaseBeanCacheEntryImpl_e813240d(); entry.setDataForPURCHASEID(dataRow.getLong(dataColumns[0]), dataRow.wasNull()); entry.setDataForTIMESTMP(dataRow.getString(dataColumns[1])); entry.setDataForITEMID(dataRow.getLong(dataColumns[2]), dataRow.wasNull()); entry.setDataForLOCATIONID(dataRow.getString(dataColumns[3])); return entry; } /** * extractPrimaryKey */ public Object extractPrimaryKey(com.ibm.ws.ejbpersistence.dataaccess.RawBeanData dataRow) throws com.ibm.ws.ejbpersistence.utilpm.ErrorProcessingResultCollectionRow, com.ibm.ws.ejbpersistence.utilpm.PersistenceManagerInternalError { int[] primaryKeyColumns = getPrimaryKeyColumns(); salesdb.PurchaseKey key= new salesdb.PurchaseKey(); key.purchaseid=new Long(dataRow.getLong(primaryKeyColumns[0])); return key; } /** * getHomeName */ public String getHomeName() { return "Purchase"; } /** * getChunkLength */ public int getChunkLength() { return 4; } }