/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package ibatis; import com.ibatis.common.resources.Resources; import com.ibatis.sqlmap.client.SqlMapClient; import com.ibatis.sqlmap.client.SqlMapClientBuilder; import java.io.Reader; /** * * @author lane */ public final class SqlMap { private static String resource = "sql-map-config.xml"; private static SqlMapClient sqlMap = null; public static SqlMapClient getInstance() { if (sqlMap != null) { System.out.println("Get the static one."); return sqlMap; }else { try { System.out.println("Create new one."); Reader reader = Resources.getResourceAsReader (resource); sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader); return sqlMap; }catch(Exception e) { System.out.println("Error in build sqlMap client. Cause: " + e); return null; } } } }