一个简单的EJB实例.用DB2连接.JSP页面.很好用.供大家学习
源代码在线查看: itembeanextractor_ff154d23.java
package salesdb.websphere_deploy.DB2UDBNT_V8_1; /** * ItemBeanExtractor_ff154d23 */ public class ItemBeanExtractor_ff154d23 extends com.ibm.ws.ejbpersistence.dataaccess.AbstractEJBExtractor { /** * ItemBeanExtractor_ff154d23 */ public ItemBeanExtractor_ff154d23() { int[] pkCols={1}; setPrimaryKeyColumns(pkCols); int[] dataCols={1,2}; 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.ItemBeanCacheEntryImpl_ff154d23 entry= new salesdb.websphere_deploy.DB2UDBNT_V8_1.ItemBeanCacheEntryImpl_ff154d23(); entry.setDataForITEMID(dataRow.getLong(dataColumns[0]), dataRow.wasNull()); entry.setDataForNAME(dataRow.getString(dataColumns[1])); 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.ItemKey key= new salesdb.ItemKey(); key.itemid=new Long(dataRow.getLong(primaryKeyColumns[0])); return key; } /** * getHomeName */ public String getHomeName() { return "Item"; } /** * getChunkLength */ public int getChunkLength() { return 2; } }