SqlMapClient對象
這個對象是iBatis操作數據庫的接口(執行CRUD等操作),它也可以執行事務管理等操作。這個類是我們使用iBATIS的最主要的類。
java:comp/env/jdbc/awpiq SqlMapIqConfig.xml
DefaultSqlMap.java
package com.bank.common; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class DefaultSqlMap { public static ApplicationContext context = null; static{ context=new ClassPathXmlApplicationContext( new String[]{"applicationContext-Iq.xml"} ); } }
SqlMapIqFactory.java
package com.bank.common; import com.ibatis.sqlmap.client.SqlMapClient; public class SqlMapIqFactory extends DefaultSqlMap { private static SqlMapClient sqlMap = null; static{ sqlMap=(SqlMapClient) context.getBean("sqlMap_iqClient"); } public static SqlMapClient getSqlMapInstance(){ return sqlMap; } }SqlMapIqConfig.xml
UserDAOImpl.java
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport; public class UserDAOImpl extends SqlMapClientDaoSupport{ }