পৃষ্ঠাসমূহ

Search Your Article

CS

 

Welcome to GoogleDG – your one-stop destination for free learning resources, guides, and digital tools.

At GoogleDG, we believe that knowledge should be accessible to everyone. Our mission is to provide readers with valuable ebooks, tutorials, and tech-related content that makes learning easier, faster, and more enjoyable.

What We Offer:

  • 📘 Free & Helpful Ebooks – covering education, technology, self-development, and more.

  • 💻 Step-by-Step Tutorials – practical guides on digital tools, apps, and software.

  • 🌐 Tech Updates & Tips – simplified information to keep you informed in the fast-changing digital world.

  • 🎯 Learning Support – resources designed to support students, professionals, and lifelong learners.

    Latest world News 

     

Our Vision

To create a digital knowledge hub where anyone, from beginners to advanced learners, can find trustworthy resources and grow their skills.

Why Choose Us?

✔ Simple explanations of complex topics
✔ 100% free access to resources
✔ Regularly updated content
✔ A community that values knowledge sharing

We are continuously working to expand our content library and provide readers with the most useful and relevant digital learning materials.

📩 If you’d like to connect, share feedback, or suggest topics, feel free to reach us through the Contact page.

Pageviews

Tuesday, January 17, 2017

iBATIS - Environment

You would have to set up a proper environment for iBATIS before starting off with actual development work. This chapter explains how to set up a working environment for iBATIS.

iBATIS Installation

Carry out the following simple steps to install iBATIS on your Linux machine −
  • Download the latest version of iBATIS from Download iBATIS.
  • Unzip the downloaded file to extract .jar file from the bundle and keep them in appropriate lib directory.
  • Set PATH and CLASSPATH variables at the extracted .jar file(s) appropriately.
$ unzip ibatis-2.3.4.726.zip
inflating: META-INF/MANIFEST.MF
   creating: doc/
   creating: lib/
 
   creating: simple_example/
   creating: simple_example/com/
   creating: simple_example/com/mydomain/
   creating: simple_example/com/mydomain/data/
   creating: simple_example/com/mydomain/domain/
 
   creating: src/
 
  inflating: doc/dev-javadoc.zip
  inflating: doc/user-javadoc.zip
  
  inflating: jar-dependencies.txt
  inflating: lib/ibatis-2.3.4.726.jar
  inflating: license.txt
  inflating: notice.txt
  inflating: release.txt
  
$pwd
/var/home/ibatis
$set PATH=$PATH:/var/home/ibatis/
$set CLASSPATH=$CLASSPATH:/var/home/ibatis\
      /lib/ibatis-2.3.4.726.jar

Database Setup

Create an EMPLOYEE table in any MySQL database using the following syntax −
mysql> CREATE TABLE EMPLOYEE (
   id INT NOT NULL auto_increment,
   first_name VARCHAR(20) default NULL,
   last_name  VARCHAR(20) default NULL,
   salary     INT  default NULL,
   PRIMARY KEY (id)
);

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 as "root" and "root" respectively.
  • Our sql statement mappings for all the operations would be described in "Employee.xml".
Based on the above assumptions, 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 cover its contents 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>
You can set the following optional properties as well using SqlMapConfig.xml file −
<property name="JDBC.AutoCommit" value="true"/>
<property name="Pool.MaximumActiveConnections" value="10"/>
<property name="Pool.MaximumIdleConnections" value="5"/>
<property name="Pool.MaximumCheckoutTime" value="150000"/> 
<property name="Pool.MaximumTimeToWait" value="500"/> 
<property name="Pool.PingQuery" value="select 1 from Employee"/> 
<property name="Pool.PingEnabled" value="false"/>

No comments:

Post a Comment