2010년 4월 6일 화요일

Ibatis 트랜잭션


try {
sqlMap.startTransaction ();
.....

sqlMap.commitTransaction ();
} finally {
sqlMap.endTransaction ();
}

==========================================================
public class IBatis {
   
    private static SqlMapClient sqlMapClient;
   
    /**
     * <pre>
     * SqlMapClient 객체를 구해오는 메소드입니다.
     * </pre>
     *
     * @return
     */
    public static synchronized SqlMapClient getSqlMapClient(){
        if(sqlMapClient==null){
            String resource = "kr/co/dungeonMaster/db/SqlMapConfig.xml";
            Reader reader;
            try {
                reader = Resources.getResourceAsReader(resource);
                sqlMapClient = SqlMapClientBuilder.buildSqlMapClient(reader);
                reader.close();
            } catch (IOException e) {
                throw new RuntimeException("Something bad happened while building the SqlMapClient instance."+ e, e);
            }
        }
        return sqlMapClient;
    }
   
}

댓글 없음:

댓글 쓰기