SqlMapConfig.xml
Harry
· 11 Sep 2026
· 9 views
The Central Configuration
SqlMapConfig.xml declares the data source, transaction settings and the list of SQL mapping files.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMapConfig PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<properties resource="jdbc.properties"/>
<transactionManager type="JDBC">
<dataSource type="SIMPLE">
<property name="JDBC.Driver" value="${jdbc.driver}"/>
<property name="JDBC.ConnectionURL" value="${jdbc.url}"/>
<property name="JDBC.Username" value="${jdbc.username}"/>
<property name="JDBC.Password" value="${jdbc.password}"/>
</dataSource>
</transactionManager>
<sqlMap resource="Customer.xml"/>
</sqlMapConfig>Data Source Types
- SIMPLE: one connection per request, lightweight.
- POOLED: a small connection pool for real applications.
- JNDI: delegate to the application server's pool.
Key Points
- SqlMapConfig wires the data source to the mappers.
- Properties let sqlMap file paths and DSNs stay external.
- POOLED is right for production; SIMPLE for learning.
- Each <sqlMap> entry loads one mapping document.