I am using the 2.1.5 Ibatis and I am following a 1.0 example (see below).
Currently I am trying to compile the below code, but the SqlMap and the
XmlSqlMapBuilder do not exist in the 2.1.5 libs. When looking through the
download I see them in the lib folder under 1-x-Compatibility. But I really do
not want to use older files. I was building a new clean project and hoping to
just use the 2.1.5 product.
So what is one to do when trying to Instantiate the SqlMap with 2.0?
Can someone give me a hand here, I have looked through all PDF doc with no
help, and the JPetstore is using the DAO manager stuff, and I am not ready for
that yet.
Thanks,
import com.ibatis.common.resources.Resources;
import com.ibatis.db.sqlmap.SqlMap;
import com.ibatis.db.sqlmap.XmlSqlMapBuilder;
public class BaseDAO {
private static Log log = LogFactory.getLog(BaseDAO.class);
private static SqlMap sqlMap = null;
static {
try {
String resource = "com/some/fun/sql-map-config.xml";
Reader reader = Resources.getResourceAsReader(resource);
log.debug("reader = "+reader );
sqlMap = XmlSqlMapBuilder.buildSqlMap(reader);
log.debug("sqlMap = "+sqlMap );
reader.close();
} catch (Exception ex) {
log.error("BaseDAO static block: " + ex);
throw new RuntimeException("Error Initializing BaseDAO :" + ex);
}
}