获得SqlMapClient 通用类
时间:2010-07-14 来源:mozhx
import java.io.IOException;
import java.io.Reader; import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder; public class IbatisUtil {
public static SqlMapClient getSqlMapClient(){
// String resource ="com/ibatis/sample/SqlMapConfig.xml";
// Reader reader;
// reader = Resources.getResourceAsReader(resource);
// XmlSqlMapClientBuilder xmlBuilder =
// new XmlSqlMapClientBuilder();
// SqlMapClient sqlMap = xmlBuilder.buildSqlMap(reader);
Reader reader = null ;
try {
reader = Resources.getResourceAsReader("SqlMapConfig.xml");
SqlMapClient sqlmap = SqlMapClientBuilder.buildSqlMapClient(reader);
return sqlmap;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}
import java.io.Reader; import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder; public class IbatisUtil {
public static SqlMapClient getSqlMapClient(){
// String resource ="com/ibatis/sample/SqlMapConfig.xml";
// Reader reader;
// reader = Resources.getResourceAsReader(resource);
// XmlSqlMapClientBuilder xmlBuilder =
// new XmlSqlMapClientBuilder();
// SqlMapClient sqlMap = xmlBuilder.buildSqlMap(reader);
Reader reader = null ;
try {
reader = Resources.getResourceAsReader("SqlMapConfig.xml");
SqlMapClient sqlmap = SqlMapClientBuilder.buildSqlMapClient(reader);
return sqlmap;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}
相关阅读 更多 +