正在加载图片...
ooAD大报告之 Petstore中EB的设计模式分析 //调用DAO,实现业务逻辑 return dao getProducts(category ID, start, count, 1) catch(CatalogDAOSys Exception se)( EJBException(se. getMessage o) } 2.1.4.3 CatalogDAo public interface CatalogDAO //声明能力 public Page getProducts(String categoryID, int start, int count, Locale 1) throws CatalogDAOSys Exception: 2.1.4. 4 Catalog DAOimpl DAOpublic class CatalogDAOImpl implements CatalogDAO public Page getProducts (String categoryID, int start, int count c= getDataSourceo. get t connection r ps =c. prepareStatement( select a productid, name, desc product a Jo + product details b on +a productid=b productid) +where locale = Resultset TYPE SCROLL INSENSITIVE ResultSet CONCUR READ ONLY Ing ps setString(2, categoryID /读取数据库 作者:张玉平,吴小静,范赟梦,张麒,罗晟,张翅 8OOAD 大报告之 PetStore 中 EJB 的设计模式分析 作者: 张 玉 平 , 吴 小 静 , 范 赟 梦 , 张麒,罗晟, 张 翅 8 //调用DAO,实现业务逻辑 return dao.getProducts(categoryID, start, count, l); } catch (CatalogDAOSysException se) { throw new EJBException(se.getMessage()); } } 2.1.4.3 CatalogDAO public interface CatalogDAO { //声明能力 public Page getProducts(String categoryID, int start, int count, Locale l) throws CatalogDAOSysException; } 2.1.4.4 CatalogDAOImpl DAOpublic class CatalogDAOImpl implements CatalogDAO { public Page getProducts(String categoryID, int start, int count, Locale l) { try { c = getDataSource().getConnection(); ps = c.prepareStatement("select a.productid, name, descn " + "from (product a join " + "product_details b on " + "a.productid=b.productid) " + "where locale = ? " + "and a.catid = ? " + "order by name", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); ps.setString(1, l.toString()); ps.setString(2, categoryID); rs = ps.executeQuery(); // 读取数据库
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有