Ibatis configuration 2

now getting SqlMapClient:
SqlAppConfig.java
 /**
 * 
 */
package com.dingfei.config;

import java.io.Reader;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

/**
 * @author Jeffy
 * 
 */
public class SqlAppConfig {
	private static final SqlMapClient sqlMap;
	static {
		try {
			String resource = "conf/SqlMapConfig.xml";
			Reader reader = Resources.getResourceAsReader(resource);
			sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
			reader.close();
		} catch (Exception e) {
			e.printStackTrace();
			throw new RuntimeException(
					"Error initializing MyAppSqlConfig class. Cause: " + e);
		}
	}

	public static SqlMapClient getSqlMapInstance() {
		return sqlMap;
	}
}

你可能感兴趣的:(java,xml,ibatis)