Blogger templates

Your Ad Here

Video

Blogroll

Blogger news

Create SqlMapConfig.xml


Consider the following:
  • We are going to use JDBC to access the database testdb.
  • JDBC driver for MySQL is "com.mysql.jdbc.Driver".
  • Connection URL is "jdbc:mysql://localhost:3306/testdb".
  • We would use username and password is "root" and "root".
  • Our sql statement mappings for all the operations would be described in "Employee.xml".
Based on the above assumption we have to create an XML configuration file with name SqlMapConfig.xml with the following content. This is where you need to provide all configurations required for iBatis:
It is important that both the files SqlMapConfig.xml and Employee.xml should be present in the class path. For now we would keep Employee.xml file empty and we would conver its content in subsequent chapters.
<?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>
<settings useStatementNamespaces="true"/>
<transactionManager type="JDBC">
<dataSource type="SIMPLE">
<property name="JDBC.Driver"
value="com.mysql.jdbc.Driver"/>
<property name="JDBC.ConnectionURL"
value="jdbc:mysql://localhost:3306/testdb"/>
<property name="JDBC.Username" value="root"/>
<property name="JDBC.Password" value="root"/>
</dataSource>
</transactionManager>
<sqlMap resource="Employee.xml"/>
</sqlMapConfig>


 

Most Reading

Stats