工 BATIS CHAPTER3 -DAO IMPLEMENTATION Byo461118 Group:o46100604610840461097,04611180461124
IBATIS CHAPTER3 --DAO IMPLEMENTATION By 0461118 Group: 0461006, 0461084, 0461097, 0461118, 0461124
Core j2EE Pattern Operation on Data Source: Public APl Interface Define All transaction Methods Independent class Implement logical data storage procedure
Core J2EE Pattern ▪ Operation on Data Source:Public API ▪ Interface Define All Transaction Methods ▪ Independent Class Implement Logical Data Storage Procedure
EXample: SQL Maps=>iBatis DAO Struts Application Insert Delete Update select Operation SQL Maps as Persistence Framework Task: Relation Table Re| ationa|DB=>ⅩML Operation Select" by hibernate Others by SQL Map
Example: SQL Maps=>iBatis DAO ▪ Struts Application Insert, Delete, Update, Select Operation SQL Maps as Persistence Framework ▪ Task: Relation Table: Relational DB => XML Operation: “Select” by Hibernate Others by SQL Map
Implementation Interface: ContactDAO o Insert a Delete Update a Select Class For SQL Map n For XMl
Implementation ▪ Interface: ContactDAO Insert Delete Update Select ▪ Class For SQL Map For XML
Implementation (Cont) 《] va classy》 《] ava class. C Contact OJDBCContactDAO a contactId: int sE》 ● addcontact o firstName: String e update Contact() lastName: String e deleteContact e selectContact() > 《] va interface》 《] ava class》 IContactDAO ⊙ XMLContactDAI0 Client uSE》 contact e addcontact ( e update Contact() e update Contact( ● deleteContact( deleteContact() ● selectcontact() selectcontact() ava classy C SQLMapContactDAO ● addcon e update Contact () e deleteContact
Implementation(Cont.)
Implementation detail Step1: Copy ibatis-dao-2 jar and ibatis-common-2 jar into WEB-INF/Lib
Implementation Detail ▪ Step1: Copy ibatis-dao-2.jar and ibatis-common-2.jar into WEB-INF/lib
Implementation Detail(cont) Step2 Create a SqlMap Config. xml file in your Java source folder
Implementation Detail(Cont.) ▪ Step2: Create a SqlMapConfig.xmlfile in your Java source folder
Implementation Detail(cont) Root element Settings useStatementNamespaces="false"/> Application-level Settings KtransactionManager type="JDBC"> Type of Transaction Mng DatasOurce type="SIMPLE"> Type of Connection Mng roperty name="JDBC Driver Information value="COM. ibm db2 jdbc. app. DB2Driver"/> roperty name="JDBC Connecti onURL value=jdbc: db2: SAMPLE"/> Property name="JDBC Username vaue="db2 admin“/> property name="JDBC Password value="admin2db"> DatasOurce> √ transacti onManager> SqlMap config File Declaration sqlMapConfig》>
Implementation Detail(Cont.) Root Element Application-level Settings Type of Transaction Mng Type of Connection Mng Information SqlMap config File Declaration
Implementation Detail(cont) Step 3: Create contactDAo java public interface ContactDAo extends DAo t public int insertcontact(Contact contact) public int update Contact(Contact contact) public Contact selectcontact(int contactid); public int deleteContact(int contactid)
Implementation Detail(Cont.) ▪ Step3: Create ContactDAO.java
Implementation Detail(cont) Step4 Create sQlmapcontactdao java
Implementation Detail(Cont.) ▪ Step4: Create SQLMapContactDAO.java