JavaEE的Spring JDBC与事务管理 实验

上传者: 38662410 | 上传时间: 2019-12-21 20:49:51 | 文件大小: 6.25MB | 文件类型: zip
一、 实验目的 1、掌握Spring JDBC的配置; 2、掌握JdbcTemplae类中增删改查方法的使用; 3、了解Spring事务管理的3个核心接口; 4、了解Spring事务管理的两种方式; 5、掌握基于XML和Annotation的声明式事务管理的使用。 二、 实验内容 1、在MySQL中创建以下三张表,其中account为账户表,book为书籍信息表,book_stock为书籍库存表。 (1)使用Spring JDBC实现书店的购书过程,即有如下一个BookShopDao接口,编写BookShopDaoImp类实现该接口中的所有方法,并通过JUnit测试这些方法。 public interface BookShopDao { //根据书号获取书的单价 //jdbcTemplate.queryForObject(sql, Double.class, isbn);rowMapper public double findBookPriceByIsbn(String isbn); //更新书的库存,使书号对应的库存减num,若库存不足,则给出提示,并且不更新 public void updateBookStock(String isbn, int num); //更新用户的账户余额:使 username 的 balance – price*num,若余额不足,则给出提示,并且不更新 public void updateUserAccount(String username,double price,int num); } (2) 在BookShopDao中添加一个purchase购书方法,其操作流程是获取书的单价->买书(更新库存)->更新账户余额,在BookShopDaoImp中实现该方法,并使用基于XML和Annotation的声明式事务管理来确保该购书过程能正常执行(这时(1)中的方法都不需进行合法性判断,直接存储数据库),通过JUnit对该方法进行测试。

文件下载

资源详情

[{"title":"( 34 个子文件 6.25MB ) JavaEE的Spring JDBC与事务管理 实验","children":[{"title":"用法以及说明文档.docx <span style='color:#111;'> 108.46KB </span>","children":null,"spread":false},{"title":"spring.sql <span style='color:#111;'> 1.67KB </span>","children":null,"spread":false},{"title":"实验.docx <span style='color:#111;'> 50.24KB </span>","children":null,"spread":false},{"title":"third","children":[{"title":".project <span style='color:#111;'> 905B </span>","children":null,"spread":false},{"title":"WebContent","children":[{"title":"WEB-INF","children":[{"title":"lib","children":[{"title":"spring-beans-4.3.6.RELEASE.jar <span style='color:#111;'> 744.83KB </span>","children":null,"spread":false},{"title":"spring-tx-4.3.6.RELEASE.jar <span style='color:#111;'> 260.92KB </span>","children":null,"spread":false},{"title":"spring-aop-4.3.6.RELEASE.jar <span style='color:#111;'> 371.00KB </span>","children":null,"spread":false},{"title":"spring-aspects-4.3.6.RELEASE.jar <span style='color:#111;'> 57.35KB </span>","children":null,"spread":false},{"title":"spring-expression-4.3.6.RELEASE.jar <span style='color:#111;'> 257.13KB </span>","children":null,"spread":false},{"title":"spring-jdbc-4.3.6.RELEASE.jar <span style='color:#111;'> 417.33KB </span>","children":null,"spread":false},{"title":"spring-core-4.3.6.RELEASE.jar <span style='color:#111;'> 1.07MB </span>","children":null,"spread":false},{"title":"aopalliance-1.0.jar <span style='color:#111;'> 4.36KB </span>","children":null,"spread":false},{"title":"aspectjweaver-1.8.10.jar <span style='color:#111;'> 1.84MB </span>","children":null,"spread":false},{"title":"commons-logging-1.2.jar <span style='color:#111;'> 60.38KB </span>","children":null,"spread":false},{"title":"spring-context-4.3.6.RELEASE.jar <span style='color:#111;'> 1.08MB </span>","children":null,"spread":false},{"title":"mysql-connector-java-5.1.8.jar <span style='color:#111;'> 706.70KB </span>","children":null,"spread":false}],"spread":false}],"spread":true},{"title":"META-INF","children":[{"title":"MANIFEST.MF <span style='color:#111;'> 39B </span>","children":null,"spread":false}],"spread":true}],"spread":true},{"title":"src","children":[{"title":"com","children":[{"title":"lyy","children":[{"title":"ApplicationContext.xml <span style='color:#111;'> 1.82KB </span>","children":null,"spread":false},{"title":"ApplicationContextXml.xml <span style='color:#111;'> 2.44KB </span>","children":null,"spread":false},{"title":"BookShopDao.java <span style='color:#111;'> 566B </span>","children":null,"spread":false},{"title":"SpringTransactionTest.java <span style='color:#111;'> 1.60KB </span>","children":null,"spread":false},{"title":"BookShopDaoImp.java <span style='color:#111;'> 1.76KB </span>","children":null,"spread":false}],"spread":true}],"spread":true}],"spread":true},{"title":".settings","children":[{"title":"org.eclipse.wst.jsdt.ui.superType.container <span style='color:#111;'> 49B </span>","children":null,"spread":false},{"title":"org.eclipse.wst.common.project.facet.core.xml <span style='color:#111;'> 305B </span>","children":null,"spread":false},{"title":"org.eclipse.jdt.core.prefs <span style='color:#111;'> 364B </span>","children":null,"spread":false},{"title":"org.eclipse.wst.jsdt.ui.superType.name <span style='color:#111;'> 6B </span>","children":null,"spread":false},{"title":"org.eclipse.wst.common.component <span style='color:#111;'> 467B </span>","children":null,"spread":false},{"title":".jsdtscope <span style='color:#111;'> 567B </span>","children":null,"spread":false}],"spread":true},{"title":"build","children":[{"title":"classes","children":[{"title":"com","children":[{"title":"lyy","children":[{"title":"SpringTransactionTest.class <span style='color:#111;'> 2.19KB </span>","children":null,"spread":false},{"title":"ApplicationContext.xml <span style='color:#111;'> 1.82KB </span>","children":null,"spread":false},{"title":"BookShopDaoImp.class <span style='color:#111;'> 2.63KB </span>","children":null,"spread":false},{"title":"ApplicationContextXml.xml <span style='color:#111;'> 2.44KB </span>","children":null,"spread":false},{"title":"BookShopDao.class <span style='color:#111;'> 349B </span>","children":null,"spread":false}],"spread":true}],"spread":true}],"spread":true}],"spread":true},{"title":".classpath <span style='color:#111;'> 1.44KB </span>","children":null,"spread":false}],"spread":true}],"spread":true}]

评论信息

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明