tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 iBATIS > Basics > Setup and Configuration

Setup and Configuration 

iBATIS is one of the best ORM mapping tools available which maps the JDBC result sets to objects. It provides a clean separation between SQLs and the objects which are mapped to result sets. This helps DB Administrators to concentrate on SQLs and Java Developers on actual results.

DB Setup

The following SQLs for Oracle helps us to setup DB schema for the tutorials.

File Name  :  
/IBATIS001/config/oracle_scripts/tables.sql 

File Name  :  
/IBATIS001/config/oracle_scripts/inserts.sql 


struts2_libs


iBatis Configuration

iBATIS requires driver name, connection url, user name and password as basic configuration parameters which has to be provided through SqlMapConfig.xml file. The SQL Mapping Configuration file has to be in classpath.

File Name  :  
/IBATIS001/config/4display/SqlMapConfig.xml 

The mapping of SQLs and result sets has to be provided through sqlMap tag. Next examples in this series shows mapping of STUDENT table with Student POJO.

File Name  :  
com/bethecoder/tutorials/ibatis/common/Student.java 
   
package com.bethecoder.tutorials.ibatis.common;

public class Student {

  private int studentId;
  private String firstName;
  private String lastName;
  private short age;
  private String phone;
  private String hobby;

  public Student() {
  }

  public Student(String firstName, String lastName, short age, String phone,
      String hobby) {
    super();
    this.firstName = firstName;
    this.lastName = lastName;
    this.age = age;
    this.phone = phone;
    this.hobby = hobby;
  }

  public int getStudentId() {
    return studentId;
  }
  public void setStudentId(int studentId) {
    this.studentId = studentId;
  }
  public String getFirstName() {
    return firstName;
  }
  public void setFirstName(String firstName) {
    this.firstName = firstName;
  }
  public String getLastName() {
    return lastName;
  }
  public void setLastName(String lastName) {
    this.lastName = lastName;
  }
  public short getAge() {
    return age;
  }
  public void setAge(short age) {
    this.age = age;
  }
  public String getPhone() {
    return phone;
  }
  public void setPhone(String phone) {
    this.phone = phone;
  }
  public String getHobby() {
    return hobby;
  }
  public void setHobby(String hobby) {
    this.hobby = hobby;
  }
  
  public String toString() {
    return "Student[" + studentId + ", "+ firstName + ", " 
          lastName + ", " + age + ", " + hobby + ", " + phone + "]";
  }
}
   



 
  


  
bl  br