Skip to end of metadata
Go to start of metadata

To process SQL statements using iBATIS, SqlMapConfig XML file and SqlMap XML file must be created. These files allow programmers to easily map JavaBeans to PreparedStatement parameters and ResultsSets.

This section describes how to create SqlMapConfig XML file, SqlMap XML file, and how to actually process SQL using this file in application. For more information on writing the sample program, please refer to the appendix.

Creating SqlMap File

SqlMap XML file is a file that specifies the SQL statements to be transferred to DB, mapping of parameters to be bound to PreparedStatement, and mappings of ResultSet.

The following is an example of writing SqlMap XML file that processes CRUD in person table (Person.xml).

After executing the SELECT statement in the <resultMap> tag, define the Map object of the data to be stored in the ResultSet, and in the <insert>, <update>, <delete>, and <select> tags, define each SQL statement for CRUD operation. do.

For more information on each tag, refer to or refer to the attached document iBATIS-SqlMaps-2-en.pdf.

Creating SqlMapConfig File

SqlMapConfig file is a SQL Maps configuration file that writes dataSource for DB connection, the path of SqlMap file, and other properties to control SqlMapClient.

The following is an example of the SqlMapConfig file (SqlMapConfigExample.xml).

In the <properties> tag, specify the path and name of the properties file in which properties defined in the form are written, in the <settings> tag, write the properties to control the SqlMapClient, and in the <transactionManager> and <dataSource>, write the DB information to connect. In addition, the <SqlMap> tag writes the path and name of the previously created SqlMap files.

For more detailed information on each tag, refer to or refer to the attached document iBATIS-SqlMaps-2-en.pdf.

Creating SqlMapConfig file - iBatis.Net Integration

How to set up the Altibase connection of SqlMap.config when connecting through ODBC is explained briefly.

First, the user needs to install the Altibase ODBC Driver and add the User DSN in the ODBC Data Source Administrator.

For how to install and configure ODBC, refer to the technical document 'Altibase Windows ODBC'.

Among the various DBMS provides defined in providers.config, the provider to use when connecting to Altibase is Odbc2.0. Write Odbc2.0 in the <provider> tag.

In the <dataSource> tag, enter the DSN added by the ODBC Data Source Administrator in connectionString.

Creating Application

CRUD operations can be processed by integrating with objects mapped to DB tables using SqlMapClient instance in the application.

In order to integrate with DB using iBATIS, the user must first obtain the SqlMapClient object through the SqlMapConfig file. Then, the user can connect to the DB by calling method corresponding to CRUD through the SqlMapClient object.

The following is an application that INSERT, UPDATE, DELETE, and SELECT data in the person table of the DB.

Ex) SimpleConnection's

First, read the SqlMapConfig file to get the SqlMapClient object. (

String resource ="SqlMapConfigExample.xml";

Reader reader = Resources.getResourceAsReader(resource);

SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);


Then, call each method of SqlMapClient class corresponding to CRUD. (

sqlMap.insert(), sqlMap.queryForList(), sqlMap.queryForObject(),sqlMap.update(), sqlMap.delete()


For detailed description of each method, refer to or refer to the attached document iBATIS-SqlMaps-2-en.pdf file.

  • No labels