Print This Post

«

»

Aug
08

Ibatis Tutorial – Sample Application Step 5

Step 5 : Create a standalone java class to run the application .


import java.io.Reader;
import java.util.List;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;
import com.model.Employee;

public class QueryEmployee {

public static void main(String[] args) {
try {
String resource = “SqlMapConfig.xml”;

Reader reader = Resources.getResourceAsReader(resource);
SqlMapClient sqlMap =
SqlMapClientBuilder.buildSqlMapClient(reader);
Integer employeePrimaryKey = new Integer(1);
Employee employee =
(Employee)sqlMap.queryForObject(“getEmployee”,
employeePrimaryKey);
System.out.println(employee.getFirstName()
+ “\t” + employee.getLastName());
}catch(Exception e) {
e.printStackTrace();
}
}
}



Technorati :

Also Read : IBatis vs Hibernate ? Which one to choose?
IBatis Tutorial – Sample Application Step 1

Related Posts with Thumbnails

1 comment

  1. IBatis Tutorial - Sample Application Step 4 - Golmuri says:

    [...] Read : IBatis vs Hibernate ? Which one to choose? IBatis Tutorial – Sample Application Step 5 Introduction to IBatis Tutorial -Part 1 Share and [...]

    Like or Dislike: Thumb up 0 Thumb down 0

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>