from article where ID = #id#
</delete>
</sqlMap>
Struts 2.1.6娼酒糞箭狼双縮殻(3)?仟療砿尖Model蚊議蝕窟?屁栽iBatis?(3)
扮寂:2011-01-20 BlogJava 伉知繰唹
寄社音勣状誼宸倖啌符猟周載鹸墫?凪糞?宸勇否叟尖盾議?泌惚寄社正誼亟議三?辛鹸崙iBatis徭揮議simple_example和議箭徨議啌符猟周?隼朔俐個匯和祥佩。
嗤阻燕、糞悶窃、燕嚥糞悶岻寂議啌符猟周?岻朔?乎恂焚担椿?僥狛Hibernate議涛嗔氏?欺椎倖方象垂銭俊佚連議塘崔猟周?輝隼?iBatis匆俶勣窃貌議猟周?軸SqlMapConfig.xml?旗鷹泌和?
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMapConfig
PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<!-- Configure a built-in transaction manager. If you''re using an
app server, you probably want to use its transaction manager
and a managed datasource -->
<transactionManager type="JDBC" commitRequired="false">
<dataSource type="SIMPLE">
<property name="JDBC.Driver" value="com.mysql.jdbc.Driver"/>
<property name="JDBC.ConnectionURL" value="jdbc:mysql://localhost:3306/simpledb"/>
<property name="JDBC.Username" value="root"/>
<property name="JDBC.Password" value="root"/>
</dataSource>
</transactionManager>
<!-- List the SQL Map XML files. They can be loaded from the
classpath, as they are here (com.domain.data) -->
<sqlMap resource="cn/simple/pojo/Article.xml"/>
<!-- List more here
<sqlMap resource="com/mydomain/data/Order.xml"/>
<sqlMap resource="com/mydomain/data/Documents.xml"/>
-->
</sqlMapConfig>
匯心宸旗鷹?匆嗤泣鹸墫?厘議傍隈揖貧?寄音阻COPY?壅待恬俐個?最最
挫阻?栖亟厘断議匍暦貸辞蚊?
package cn.simple.manager;
import java.io.IOException;
import java.io.Reader;
import java.sql.SQLException;
import java.util.List;
import cn.simple.pojo.Article;
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;
public class ArticleManager {
/** *//**
* SqlMapClient instances are thread safe, so you only need one. In this
* case, we''ll use a static singleton. So sue me. ;-)
*/
private static SqlMapClient sqlMapper;
/** *//**
* It''s not a good idea to put code that can fail in a class initializer,
* but for sake of argument, here''s how you configure an SQL Map.
*/
static {
try {
|